0

I am not able to view Junit tests in Sonarqube coverage report. We are running the pipeline in bitbucket and project is based on SAP hybris.

bit-bucket-pipeline.yml

mage: atlassian/default-image:3
clone:
  lfs: true
pipelines:
  custom:
    qg-sonarqube-main:
      - step:
          name: 'sq init'
          image: atlassian/default-image:3
          script:
            - |
              echo "start notification"
              echo "install java"
              apt update
              apt install -y --no-install-recommends openjdk-11-jdk rsync tree
              java --version
              echo "sonarqube scan of current branch; build dir $BITBUCKET_CLONE_DIR"
              # assembly first
              echo "download scanner-cli"
              wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-     4.7.0.2747.zip -O $BITBUCKET_CLONE_DIR/sonarcli.zip
              unzip -q $BITBUCKET_CLONE_DIR/sonarcli.zip -d $BITBUCKET_CLONE_DIR
              ln -s $BITBUCKET_CLONE_DIR/sonar-scanner-4.7.0.2747/bin/sonar-scanner /bin/sonar-scanner
              /bin/sonar-scanner -v
              echo "hybris ootb assembly"
              unzip -q ootb/CXCOM200500P_27-70004955.ZIP -d $BITBUCKET_CLONE_DIR
              echo "unzip and copy modules"
              unzip -q ootb/modules.zip -d $BITBUCKET_CLONE_DIR/hybris/bin/
              echo "move sonar project configuration"
              mv sonar-project.properties hybris/sonar-project.properties
              echo "node version"
              node -v
              echo "move the customcode"
              mv bin/custom hybris/bin/
              echo "build the box"
              cd hybris/bin/platform
              . ./setantenv.sh
              echo | ant clean
              cd $BITBUCKET_CLONE_DIR
              rsync -vau config/ hybris/config/
              echo "check config dir"
              cd hybris/bin/platform
              ant customize
              echo "copy valid props and localextensions taken from valid assembly"
              ant build all
              echo "scan"
              cd $BITBUCKET_CLONE_DIR/hybris/
              TODAY=$(date +'%d%m%Y')
              echo "code version $BITBUCKET_BUILD_NUMBER.$TODAY"
              /bin/sonar-scanner -Dsonar.login="$SONAR_LOGIN" -Dsonar.projectKey=alcon-"$BITBUCKET_BRANCH" -Dsonar.projectName=alcon-"$BITBUCKET_BRANCH" -Dsonar.projectVersion="$BITBUCKET_BUILD_NUMBER.$TODAY"
              echo "waiting for CE"
              # get ceTaskUrl var
              source .scannerwork/report-task.txt
              # up to 30 min
              for _ in {0..60}; do
              status=$(curl -s -H "Accept: application/json" -u "$SONAR_LOGIN:" $ceTaskUrl | jq -r .task.status)
              case $status in
              SUCCESS)
                  echo "notification about success"
                  echo "Task finished"
                  echo "Project dashboard: $dashboardUrl"
                  exit 0
                  ;;
              PENDING | IN_PROGRESS)
                  echo "Task still in progress"
                  sleep 30
                  ;;
              FAILED)
                  echo "notification about fail"
                  echo Got FAILED task status, exit
                  exit 1
                  ;;
              *)
                  echo "Unsupported task status: $status"
                  sleep 30
                  ;;
              esac
              done
              echo "Project dashboard: $dashboardUrl"

====================

Sonar-project.properties:

sonar.sources=bin/custom/
sonar.sourceEncoding=UTF-8
sonar.pdf.skip=true
sonar.language=java
sonar.java.source=1.8
sonar.java.binaries=bin/custom/
sonar.host.url=https://b2bint.sonarqube.alconcloud.com
Ole V.V.
  • 81,772
  • 15
  • 137
  • 161

0 Answers0