Must-share information:
- which versions are you using SonarQube? 10.4.1 Enterprise Edition, sonarqube-scan-action v2.2
- how is SonarQube deployed? On-premises, standard server installation
- what are you trying to achieve? Cache SonarQube scanner files on GitHub Actions
- what have you tried so far to achieve this? Downgraded sonarqube-scan-action to v2.0.2
We are using the standard GitHub Actions cache action to cache the scanner files because it takes a long time to download:
- name: SonarQube Cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.sonar/cache
key: ${{ runner.os }}-sonar
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@v2.0.2
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}
SONAR_USER_HOME: ${{ github.workspace }}/.sonar
with:
args: >
-Dsonar.projectKey=${{ github.event.repository.name }}
-Dsonar.projectVersion=${{ inputs.project-version }}
This works fine when using sonarqube-scan-action v2.0.2. After the first build, files under ${{ github.workspace }}/.sonar/cache are cached and future scans run much quicker.
Upgrading to sonarqube-scan-action v2.2 makes the cache action Post job cleanup fail like this:
> Post job cleanup.
/usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/ai-rapportering/ai-rapportering --files-from manifest.txt --use-compress-program zstdmt
/usr/bin/tar: .sonar/cache/3ede12e96a509e101c6eab2aa4706c50/sonar-php-plugin.jar_unzip: Cannot open: Permission denied
/usr/bin/tar: .sonar/cache/0c7e084443770eb32129caa9121bb60e/sonar-ruby-plugin.jar_unzip: Cannot open: Permission denied
...
/usr/bin/tar: Exiting with failure status due to previous errors
Warning: Failed to save: "/usr/bin/tar" failed with error: The process '/usr/bin/tar' failed with exit code 2
The cache action is clearly not allowed to read the scanner files.
I suspect this could be due to the fact that in a recent commit the user is explicitly set in the Dockerfile as:
USER 0
even though the GitHub documentation says:
Ensure your Dockerfile does not set the USER instruction, otherwise you will not be able to access GITHUB_WORKSPACE.
We would of course like to upgrade sonarqube-scan-action to the latest version, but we need to be able to cache the scanner files. Could you please look into this?