I’ve been running the Azure DevOps plugins for SonarQube server (Community build v24.12.0.100206) with quite a bit of success; however, when I try to enable caching of the SonarQube tasks to improve performance of the pipeline according to the published instructions, then the build fails at the post-cache execution.
I’ve configured the .NET scanner as follows:
- task: Cache@2
inputs:
key: '"SonarScanner" | ".NET" | "$(Agent.OS)"'
path: '$(Agent.ToolsDirectory)/SonarScanner .NET'
- task: SonarQubePrepare@7
inputs:
SonarQube: 'SonarQube'
scannerMode: 'dotnet'
projectKey: '${{parameters.sonarProjectKey}}'
projectVersion: '${{parameters.version}}'
# builds and tests go in here
- task: SonarQubeAnalyze@7
- task: SonarQubePublish@7
inputs:
pollingTimeoutSec: '300'
The Cache step produces the following output with no issue:
Starting: Cache SonarScanner
==============================================================================
Task : Cache
Description : Cache files between runs
Version : 2.198.0
Author : Microsoft Corporation
Help : https://aka.ms/pipeline-caching-docs
==============================================================================
Resolving key:
- "SonarScanner" [string]
- ".NET" [string]
- "Windows_NT" [string]
Resolved to: "SonarScanner"|".NET"|"Windows_NT"
Using default max parallelism.
Max dedup parallelism: 192
DomainId: 0
ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session b45e5e3d-e2cc-4b2e-aa14-8d7920950242
Hashtype: Dedup64K
Getting a pipeline cache artifact with one of the following fingerprints:
Fingerprint: `"SonarScanner"|".NET"|"Windows_NT"`
There is a cache miss.
ApplicationInsightsTelemetrySender correlated 1 events with X-TFS-Session b45e5e3d-e2cc-4b2e-aa14-8d7920950242
Finishing: Cache SonarScanner
and all the other steps run without problem, until the Post-Job:Cache step:
Starting: Cache SonarScanner
==============================================================================
Task : Cache
Description : Cache files between runs
Version : 2.198.0
Author : Microsoft Corporation
Help : https://aka.ms/pipeline-caching-docs
==============================================================================
Resolving key:
- "SonarScanner" [string]
- ".NET" [string]
- "Windows_NT" [string]
Resolved to: "SonarScanner"|".NET"|"Windows_NT"
Using default max parallelism.
Max dedup parallelism: 192
DomainId: 0
ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session 4145e2aa-a339-48af-9c86-698ef0d608e9
Hashtype: Dedup64K
Getting a pipeline cache artifact with one of the following fingerprints:
Fingerprint: `"SonarScanner"|".NET"|"Windows_NT"`
There is a cache miss.
tar: could not chdir to 'C:\hostedtoolcache\windows\SonarScanner .NET'
ApplicationInsightsTelemetrySender correlated 1 events with X-TFS-Session 4145e2aa-a339-48af-9c86-698ef0d608e9
##[error]Process returned non-zero exit code: 1
Finishing: Cache SonarScanner
which results in the pipeline being marked as failed (despite everything working, all my analysis results are published to SonarQube correctly).
If I remove the Cache task then the pipeline executes to completion successfully, and I’m doing what’s in the documentation - is there some extra configuration of the Cache task that I’m missing?