From fd3db35a1b8a1153829f454ff0d30e83484ee726 Mon Sep 17 00:00:00 2001 From: Robi Nino Date: Tue, 10 Dec 2024 13:52:08 +0200 Subject: [PATCH] Revert default server ID removal (#234) --- lib/utils.js | 8 ++++---- package-lock.json | 2 +- src/utils.ts | 8 ++++---- test/main.spec.ts | 11 ++--------- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index ef210422..02548588 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -350,10 +350,10 @@ class Utils { return Utils.getRunDefaultServerId(); } /** - * Return a server ID that is unique for this workflow run based on the GitHub repository and run ID. + * Return the default server ID for JFrog CLI server configuration. */ static getRunDefaultServerId() { - return [Utils.SETUP_JFROG_CLI_SERVER_ID_PREFIX, process.env.GITHUB_REPOSITORY, process.env.GITHUB_RUN_ID].join('-'); + return Utils.SETUP_JFROG_CLI_SERVER_ID; } static setCliEnv() { Utils.exportVariableIfNotSet('JFROG_CLI_ENV_EXCLUDE', '*password*;*secret*;*key*;*token*;*auth*;JF_ARTIFACTORY_*;JF_ENV_*;JF_URL;JF_USER;JF_PASSWORD;JF_ACCESS_TOKEN'); @@ -773,8 +773,8 @@ Utils.LATEST_CLI_VERSION = 'latest'; Utils.LATEST_RELEASE_VERSION = '[RELEASE]'; // Placeholder CLI version to use to keep 'latest' in cache. Utils.LATEST_SEMVER = '100.100.100'; -// The prefix for the default server id name for JFrog CLI config -Utils.SETUP_JFROG_CLI_SERVER_ID_PREFIX = 'setup-jfrog-cli-server'; +// The default server id name for separate env config +Utils.SETUP_JFROG_CLI_SERVER_ID = 'setup-jfrog-cli-server'; // Environment variable to hold all configured server IDs, separated by ';' Utils.JFROG_CLI_SERVER_IDS_ENV_VAR = 'SETUP_JFROG_CLI_SERVER_IDS'; // Directory name which holds markdown files for the Workflow summary diff --git a/package-lock.json b/package-lock.json index 88880cd4..173a83c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@jfrog/setup-jfrog-cli", - "version": "4.4.2", + "version": "4.5.0", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { diff --git a/src/utils.ts b/src/utils.ts index ed9680c6..c5907a8c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -33,8 +33,8 @@ export class Utils { private static readonly LATEST_RELEASE_VERSION: string = '[RELEASE]'; // Placeholder CLI version to use to keep 'latest' in cache. public static readonly LATEST_SEMVER: string = '100.100.100'; - // The prefix for the default server id name for JFrog CLI config - public static readonly SETUP_JFROG_CLI_SERVER_ID_PREFIX: string = 'setup-jfrog-cli-server'; + // The default server id name for separate env config + public static readonly SETUP_JFROG_CLI_SERVER_ID: string = 'setup-jfrog-cli-server'; // Environment variable to hold all configured server IDs, separated by ';' public static readonly JFROG_CLI_SERVER_IDS_ENV_VAR: string = 'SETUP_JFROG_CLI_SERVER_IDS'; // Directory name which holds markdown files for the Workflow summary @@ -398,10 +398,10 @@ export class Utils { } /** - * Return a server ID that is unique for this workflow run based on the GitHub repository and run ID. + * Return the default server ID for JFrog CLI server configuration. */ static getRunDefaultServerId(): string { - return [Utils.SETUP_JFROG_CLI_SERVER_ID_PREFIX, process.env.GITHUB_REPOSITORY, process.env.GITHUB_RUN_ID].join('-'); + return Utils.SETUP_JFROG_CLI_SERVER_ID; } public static setCliEnv() { diff --git a/test/main.spec.ts b/test/main.spec.ts index 10a63b2e..ce4a6444 100644 --- a/test/main.spec.ts +++ b/test/main.spec.ts @@ -156,15 +156,8 @@ function testConfigCommand(expectedServerId: string) { } describe('JFrog CLI Configuration', () => { - beforeAll(() => { - process.env.GITHUB_REPOSITORY = 'owner/repo'; - process.env.GITHUB_RUN_ID = '1'; - }); - afterAll(() => { - ['GITHUB_REPOSITORY', 'GITHUB_RUN_ID', Utils.JFROG_CLI_SERVER_IDS_ENV_VAR].forEach((envKey) => { - delete process.env[envKey]; - }); + delete process.env[Utils.JFROG_CLI_SERVER_IDS_ENV_VAR]; }); const myCore: jest.Mocked = core as any; @@ -187,7 +180,7 @@ describe('JFrog CLI Configuration', () => { }); test('Get default server ID', async () => { - expect(Utils.getRunDefaultServerId()).toStrictEqual('setup-jfrog-cli-server-owner/repo-1'); + expect(Utils.getRunDefaultServerId()).toStrictEqual('setup-jfrog-cli-server'); }); });