SonarScan not recognising python code at the source directory

21 Views Asked by At

Sonar scan result is displayed with 0 issues/bug. I found that it's not recognising any python files at the source directory

  1. I tried with all the pyhton files at root and specifying sonar.sources = .
  2. In other approach I'm trying to put all python files into src folder and changing to sonar.sources = src - in this case during build i get error saying invalid sonar.sources value

Docker file

ARG scannerVersion=4.6.2
ARG sonarProjKey=mySonarPRoject

FROM docker.prod.fgh.com/ade/eda_:prod-2

RUN adduser --system --uid 1200 --group --shell /sbin/nologin --home /opt/app/ app

WORKDIR /opt/app

RUN chmod 777 /opt/app

EXPOSE 5000/tcp

ENV PYTHONPATH='/opt/app/src'
RUN echo $PYTHONPATH

COPY requirements.txt ./

RUN pip3 install -i https://repository.fgh.com/repository/pypi/simple/ -r requirements.txt

COPY src/ ./src/


#============>Sonarscan<============
FROM docker.prod.fgh.com/strati/docker-sonarqube-scanner:${scannerVersion} as sonar
ARG sonarOpts   
ARG sonarProjKey
WORKDIR /home/site/wwwroot
RUN echo '===== BEGIN SONAR PHASE ====='
RUN sonar-scanner --debug -Dsonar.projectKey=${sonarProjKey} ${sonarOpts}

configuration

      buildArgs:
    sonarProjKey: 'ADEEC-adextractors'
    sonarOpts: "-Dsonar.sources=src
      -Dsonar.projectKey=mySonarProject
      -Dsonar.projectVersion={{$.kitt.build.version}}
      -Dsonar.language=py
      -Dsonar.sourceEncoding=UTF-8
      -Dsonar.python.coverage.reportPaths=coverage.xml
      -Dsonar.projectName=mySonarProject
      -Dsonar.pullrequest.github.repository={{ $.kitt.build.commitEvent.repo.org }}/{{ $.kitt.build.commitEvent.repo.name }}
      -Dsonar.host.url=http://sonar.looper.prod.fgh.com"

Can anyone please tell me where I'm doing wrong in the configuration?

0

There are 0 best solutions below