I am working on a Dev Azure pipeline which is runnig couple of stages which have tasks for preparing sonar report. The important parts of stages which I want to focus on look like:
build_and_sonar_prepare:
- task: SonarQubePrepare@6
displayName: prepare_sonar
inputs:
SonarQube: ${{ parameters.SonarQube}}
scannerMode: 'Other'
- task: Bash@3
displayName: scan_sonar
inputs:
targetType: 'inline'
script: |
mvn sonar:sonar other commands
sonar_publish:
- task: SonarQubePublish@6
inputs:
pollingTimeoutSec: '300'
The build_and_sonar_prepare is not managed by me, its part of a template which I am reusing. It runs fine and generates proper sonar report with a link to sonar server.
The stage which I have controll is sonar_publish, where I would like to only publish the results in order to see the results of the report in Azure Devops Pipeline summary (I have created separate question for that: (Azure Devops Pipeline, show link do Sonar report on the summary page of Pipeline Run)
What happens here is
- SonarQubePrepare is being called with a proper working connection to SonarQube ${{ parameters.SonarQube}}, which is managed by Azure and its working fine.
- the mvn sonar:sonar is being called, instead of SonarCubeAnalyze and unfortunately I cannot change it, because its part of the template
- SonarQubePublish@6 is being called, but from another stage
After I run this pipeline I am getting an error:
##[error]Variables are missing. Please make sure that you are running the Prepare and Analyze tasks before running the Publish task.
I have tried to put the SonarCubeAnalyze in my stage, before I call Publish but it also failed. I have also ensured that all files generated by sonar report are copied in the workspace of sonar_publish (using CopyFiles@2 and PublishBuildArtifacts@1 in the build_and_sonar_prepare stage and CopyFiles@2 in the sonar_publish stage)
So far without success.
I wonder if it is possible to Publish sonar report with this setup?
I also would like to know which variables are missing and how to check if they exist in the sonar_publish stage and what are their values?