mirror of
https://github.com/SonarSource/sonarqube-scan-action.git
synced 2026-06-05 17:10:31 +03:00
SQSCANGHA-127 Rename downloaded file to .zip before extraction on Windows
PowerShell 5.1, used on some Windows GitHub Actions runners, requires Expand-Archive to receive a file with a .zip extension. The @actions/tool-cache downloadTool function saves to a temp path without any extension, causing extraction to fail on PS 5.1. Rename the file to add .zip before calling extractZip. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
import * as core from "@actions/core";
|
||||
import * as tc from "@actions/tool-cache";
|
||||
import * as fs from "node:fs/promises";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import {
|
||||
@@ -29,6 +30,15 @@ import { verifySignature } from "./gpg-verification.js";
|
||||
|
||||
const TOOLNAME = "sonar-scanner-cli";
|
||||
|
||||
async function ensureZipExtension(filePath) {
|
||||
if (filePath.endsWith(".zip")) {
|
||||
return filePath;
|
||||
}
|
||||
const zipPath = `${filePath}.zip`;
|
||||
await fs.rename(filePath, zipPath);
|
||||
return zipPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the Sonar Scanner CLI for the current environment and cache it.
|
||||
*/
|
||||
@@ -76,7 +86,9 @@ export async function installSonarScanner({
|
||||
await verifySignature(downloadPath, signaturePath);
|
||||
}
|
||||
|
||||
const extractedPath = await tc.extractZip(downloadPath);
|
||||
// PowerShell 5.1 (used on some Windows agents) requires the .zip extension for Expand-Archive
|
||||
const extractInput = await ensureZipExtension(downloadPath);
|
||||
const extractedPath = await tc.extractZip(extractInput);
|
||||
|
||||
// Find the actual scanner directory inside the extracted folder
|
||||
const scannerPath = path.join(
|
||||
|
||||
Reference in New Issue
Block a user