I have a NodeJs app and a pipeline that runs for my Azure repository:
jobs-sonar-scan.yaml – pipeline
jobs:
- job: SonarAnalysis
displayName: 'Sonar Analysis'
steps:
# Prepare Analysis Configuration task
- task: SonarQubePrepare@6
inputs:
SonarQube: 'my-azure-sonar-connection'
scannerMode: 'my-name'
configMode: 'manual'
cliProjectKey: 'my-cli'
extraProperties: |
sonar.tests.inclusions=**/*.test.ts
sonar.exclusions=**/node_modules/*
# Run Code Analysis task
- task: SonarQubeAnalyze@6
inputs:
jdkVersion: 'JAVA_HOME_17_X64' # Fixed typo here
# Publish Quality Gate Result task
- task: SonarQubePublish@6
inputs:
pollingTimeoutSec: '300'
The pipeline runs well and sends the report back to the Sonar dashboard. However, at the end of the pipeline, I want to generate and publish an artifact file with the destination report/sonar-report.json. I have tried something like this:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
New-Item -ItemType Directory -Path "$(Build.ArtifactStagingDirectory)/report/sonar" -Force
- task: CopyFiles@2
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: '**/$(BuildConfiguration)/**/?(*.exe|*.dll|*.pdb)'
targetFolder: '$(Build.ArtifactStagingDirectory)/report/sonar'
cleanTargetFolder: true # Optionally clean the target folder before copying
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)/report/sonar'
artifactName: drop```
But it doesn't work. I am fairly new to this kind of stuff. Thank you!
I want to generate an artifact report from my SonarQube scan in the pipeline summary.