@@ -31343,11 +31343,34 @@ exports.IQ_CLI_JAR = 'sonatype-iq-cli.jar';
3134331343exports.IQ_VERSION_TO_COMPLETE = '1.{iq-cli-version}.0-01';
3134431344exports.DOWNLOAD_URL = 'https://download.sonatype.com/clm/scanner/nexus-iq-cli-{iq-cli-version}.jar';
3134531345exports.MINIMUM_SUPPORTED_IQ_VERSION = 137;
31346- exports.LATEST_IQ_CLI_VERSION = '2.4.2 -01'; // This should be updated to the latest IQ CLI version with each release
31346+ exports.LATEST_IQ_CLI_VERSION = '2.4.3 -01'; // This should be updated to the latest IQ CLI version with each release
3134731347exports.IQ_CLI_VERSION = 'iq-cli-version';
3134831348exports.IQ_CLI_DOWNLOAD_URL = 'iq-cli-download-url';
3134931349
3135031350
31351+ /***/ }),
31352+
31353+ /***/ 848:
31354+ /***/ ((__unused_webpack_module, exports) => {
31355+
31356+ "use strict";
31357+
31358+ /*
31359+ * Copyright (c) 2023-present Sonatype, Inc. All rights reserved.
31360+ * Includes the third-party code listed at https://links.sonatype.com/products/clm/attributions.
31361+ * "Sonatype" is a trademark of Sonatype, Inc.
31362+ */
31363+ Object.defineProperty(exports, "__esModule", ({ value: true }));
31364+ exports.getNextDownloadUrl = getNextDownloadUrl;
31365+ // Given a url like: download.sonatype.com/scanner/nexus-iq-cli-1.178.0-05.jar
31366+ // returns download.sonatype.com/scanner/nexus-iq-cli-1.178.0-06.jar
31367+ function getNextDownloadUrl(url) {
31368+ const currentBuildNumber = url.substring(url.length - 6, url.length - 4);
31369+ const nextBuildNumber = (parseInt(currentBuildNumber) + 1).toString().padStart(2, '0');
31370+ return url.replace(currentBuildNumber, nextBuildNumber);
31371+ }
31372+
31373+
3135131374/***/ }),
3135231375
3135331376/***/ 8917:
@@ -31439,13 +31462,37 @@ function getValidatedIQCLIVersion() {
3143931462 if (input === 'latest') {
3144031463 return constants_1.LATEST_IQ_CLI_VERSION;
3144131464 }
31465+ // Here only for backwards compatibility, see docs on function
3144231466 if (/^\d+$/.test(input)) {
31443- if (parseInt(input) < constants_1.MINIMUM_SUPPORTED_IQ_VERSION) {
31444- throw Error(`IQ minimum supported version is ${constants_1.MINIMUM_SUPPORTED_IQ_VERSION}`);
31445- }
31446- return constants_1.IQ_VERSION_TO_COMPLETE.replace('{iq-cli-version}', input);
31467+ return getIqFromMinorVersion(input);
31468+ }
31469+ // This is similar to 2.1.0-01, just return..
31470+ // Here the user provided a full version (major.minor.patch-build-number)
31471+ // This is what we are trying to build anyway so no need for any additional logic..
31472+ if (/^\d\.\d+\.\d+-\d+$/.test(input)) {
31473+ return input;
31474+ }
31475+ // If the provided value does not match 2.1.0 (or similar) - warn and return
31476+ // This can happen when user provides 2.10 or similar (which is insufficient)
31477+ if (!/^\d+\.\d+\.\d+$/.test(input)) {
31478+ throw Error(`Provided IQ CLI version must be in the form of major.minor.patch`);
31479+ }
31480+ // At this point we are handling a provided input that is major.minor.patch
31481+ // Concat the build number -01 and return
31482+ // We will handle other possibilities later (-02, -03) if needed
31483+ return input.concat('-01');
31484+ }
31485+ // The logic within this function is *deprecated* and *not* documented.
31486+ // If the provided input is a single decimal (like 180, 185 and so on..),
31487+ // this returns 1.{provided-version}.0-01
31488+ // This works if all IQ CLI versions were 1.x but we also have 2.x so the provided value is ambiguous.
31489+ function getIqFromMinorVersion(input) {
31490+ core.warning('Providing a minor version only is deprecated and only works for IQ CLI 1.x');
31491+ core.warning('Input the desired CLI version in the major.minor.patch form.');
31492+ if (parseInt(input) < constants_1.MINIMUM_SUPPORTED_IQ_VERSION) {
31493+ throw Error(`IQ minimum supported version is ${constants_1.MINIMUM_SUPPORTED_IQ_VERSION}`);
3144731494 }
31448- return input;
31495+ return constants_1.IQ_VERSION_TO_COMPLETE.replace('{iq-cli-version}', input) ;
3144931496}
3145031497
3145131498
@@ -31495,6 +31542,7 @@ const path_1 = __importDefault(__nccwpck_require__(1017));
3149531542const fs_1 = __nccwpck_require__(7147);
3149631543const constants_1 = __nccwpck_require__(9733);
3149731544const get_validated_iq_cli_version_1 = __nccwpck_require__(3391);
31545+ const get_next_download_url_1 = __nccwpck_require__(848);
3149831546const get_semver_version_1 = __nccwpck_require__(8917);
3149931547/**
3150031548 * The main function for the action.
@@ -31543,7 +31591,23 @@ async function run() {
3154331591 else {
3154431592 core.debug(`Downloading IQ CLI version ${iqCliVersion}`);
3154531593 }
31546- const iqCliPath = await tc.downloadTool(validatedDownloadUrl, constants_1.IQ_CLI_JAR);
31594+ let iqCliPath;
31595+ for (let i = 1; i < 10; i++) {
31596+ try {
31597+ core.debug(`Attempting to download IQ CLI from: ${validatedDownloadUrl}`);
31598+ iqCliPath = await tc.downloadTool(validatedDownloadUrl, constants_1.IQ_CLI_JAR);
31599+ core.info(`IQ CLI downloaded from: ${validatedDownloadUrl}`);
31600+ break;
31601+ }
31602+ catch (error) {
31603+ core.debug(`Failed to download from: ${validatedDownloadUrl}`);
31604+ validatedDownloadUrl = (0, get_next_download_url_1.getNextDownloadUrl)(validatedDownloadUrl);
31605+ }
31606+ }
31607+ if (!iqCliPath) {
31608+ core.warning(`Failed to download the custom IQ version: ${iqCliVersion}`);
31609+ throw Error(`Failed to download the custom IQ version: ${iqCliVersion}`);
31610+ }
3154731611 core.debug(`Download path is: ${iqCliPath}`);
3154831612 cachedPath = await tc.cacheFile(iqCliPath, constants_1.IQ_CLI_JAR, 'iq-cli', semverVersion);
3154931613 // Delete the downloaded file after caching
0 commit comments