mirror of
https://github.com/SonarSource/sonarqube-scan-action.git
synced 2026-06-07 09:51:23 +03:00
SQSCANGHA-135 Fix scanner binaries always re-downloaded due to incompatible 4-part version
GitHub's tool-cache library uses semver.clean() to look up cached tools, which returns null for 4-part version strings like "8.0.1.6346". This caused findAllVersions() to filter out any cached directory, resulting in a cache miss on every run. The fix converts the 4-part version to a semver pre-release format (e.g. "8.0.1-build.6346") for tool-cache operations, while keeping the original version string for download URLs and zip extraction. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+16
-2
@@ -3862,6 +3862,19 @@ function getScannerDownloadURL({
|
||||
const scannerDirName = (version, flavor) =>
|
||||
`sonar-scanner-${version}-${flavor}`;
|
||||
|
||||
/**
|
||||
* Converts a 4-part version string (e.g. "8.0.1.6346") to a SemVer 2.0 compatible
|
||||
* string (e.g. "8.0.1-build.6346") for use with GitHub's tool-cache library,
|
||||
* which requires SemVer-compliant version strings.
|
||||
*/
|
||||
function toSemVer(version) {
|
||||
const parts = version.split(".");
|
||||
if (parts.length === 4) {
|
||||
return `${parts[0]}.${parts[1]}.${parts[2]}-build.${parts[3]}`;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
/*
|
||||
* sonarqube-scan-action
|
||||
* Copyright (C) 2025 SonarSource SA
|
||||
@@ -4151,9 +4164,10 @@ async function installSonarScanner({
|
||||
skipSignatureVerification = false,
|
||||
}) {
|
||||
const flavor = getPlatformFlavor(os$1.platform(), os$1.arch());
|
||||
const semVerVersion = toSemVer(scannerVersion);
|
||||
|
||||
// Check if tool is already cached
|
||||
let toolDir = find(TOOLNAME, scannerVersion, flavor);
|
||||
let toolDir = find(TOOLNAME, semVerVersion, flavor);
|
||||
|
||||
if (!toolDir) {
|
||||
info(
|
||||
@@ -4196,7 +4210,7 @@ async function installSonarScanner({
|
||||
scannerDirName(scannerVersion, flavor)
|
||||
);
|
||||
|
||||
toolDir = await cacheDir(scannerPath, TOOLNAME, scannerVersion, flavor);
|
||||
toolDir = await cacheDir(scannerPath, TOOLNAME, semVerVersion, flavor);
|
||||
|
||||
info(`Sonar Scanner CLI cached to: ${toolDir}`);
|
||||
} else {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user