diff --git a/lib/cleanup.js b/lib/cleanup.js index 52fa3fbc9..adb012d2e 100644 --- a/lib/cleanup.js +++ b/lib/cleanup.js @@ -137,7 +137,13 @@ function collectAndPublishBuildInfoIfNeeded() { // We allow this step to fail, and we don't want to fail the entire build publish if they do. try { core.startGroup('Collect the Git information'); - yield utils_1.Utils.runCli(['rt', 'build-add-git'], { cwd: workingDirectory }); + const gitDir = require('path').join(workingDirectory, '.git'); + if (require('fs').existsSync(gitDir)) { + yield utils_1.Utils.runCli(['rt', 'build-add-git'], { cwd: workingDirectory }); + } + else { + core.info('No .git directory found. Skipping Git information collection.'); + } } catch (error) { core.warning('Failed while attempting to collect Git information: ' + error); diff --git a/lib/utils.js b/lib/utils.js index c5c6c42a7..1f9b70440 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -255,6 +255,7 @@ class Utils { } Utils.exportVariableIfNotSet('JFROG_CLI_ENV_EXCLUDE', '*password*;*secret*;*key*;*token*;*auth*;JF_ARTIFACTORY_*;JF_ENV_*;JF_URL;JF_USER;JF_PASSWORD;JF_ACCESS_TOKEN'); Utils.exportVariableIfNotSet('JFROG_CLI_OFFER_CONFIG', 'false'); + Utils.exportVariableIfNotSet('JFROG_CLI_AVOID_NEW_VERSION_WARNING', 'true'); Utils.exportVariableIfNotSet('CI', 'true'); Utils.exportVariableIfNotSet('JFROG_CLI_SOURCECODE_REPOSITORY', (_a = process.env.GITHUB_REPOSITORY) !== null && _a !== void 0 ? _a : ''); Utils.exportVariableIfNotSet('JFROG_CLI_CI_JOB_ID', (_b = process.env.GITHUB_WORKFLOW) !== null && _b !== void 0 ? _b : ''); diff --git a/src/cleanup.ts b/src/cleanup.ts index d5f72abb6..5360ac177 100644 --- a/src/cleanup.ts +++ b/src/cleanup.ts @@ -105,7 +105,12 @@ async function collectAndPublishBuildInfoIfNeeded() { // We allow this step to fail, and we don't want to fail the entire build publish if they do. try { core.startGroup('Collect the Git information'); - await Utils.runCli(['rt', 'build-add-git'], { cwd: workingDirectory }); + const gitDir: string = require('path').join(workingDirectory, '.git'); + if (require('fs').existsSync(gitDir)) { + await Utils.runCli(['rt', 'build-add-git'], { cwd: workingDirectory }); + } else { + core.info('No .git directory found. Skipping Git information collection.'); + } } catch (error) { core.warning('Failed while attempting to collect Git information: ' + error); } finally { diff --git a/src/utils.ts b/src/utils.ts index 91d2212ca..ef4168309 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -290,6 +290,7 @@ export class Utils { '*password*;*secret*;*key*;*token*;*auth*;JF_ARTIFACTORY_*;JF_ENV_*;JF_URL;JF_USER;JF_PASSWORD;JF_ACCESS_TOKEN', ); Utils.exportVariableIfNotSet('JFROG_CLI_OFFER_CONFIG', 'false'); + Utils.exportVariableIfNotSet('JFROG_CLI_AVOID_NEW_VERSION_WARNING', 'true'); Utils.exportVariableIfNotSet('CI', 'true'); Utils.exportVariableIfNotSet('JFROG_CLI_SOURCECODE_REPOSITORY', process.env.GITHUB_REPOSITORY ?? ''); Utils.exportVariableIfNotSet('JFROG_CLI_CI_JOB_ID', process.env.GITHUB_WORKFLOW ?? ''); @@ -479,8 +480,8 @@ export class Utils { if (!jfrogCredentials.jfrogUrl) { throw new Error( `'download-repository' input provided, but no JFrog environment details found. ` + - `Hint - Ensure that the JFrog connection details environment variables are set: ` + - `either a Config Token with a JF_ENV_ prefix or separate env config (JF_URL, JF_USER, JF_PASSWORD, JF_ACCESS_TOKEN)`, + `Hint - Ensure that the JFrog connection details environment variables are set: ` + + `either a Config Token with a JF_ENV_ prefix or separate env config (JF_URL, JF_USER, JF_PASSWORD, JF_ACCESS_TOKEN)`, ); } serverObj.artifactoryUrl = jfrogCredentials.jfrogUrl.replace(/\/$/, '') + '/artifactory';