Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 : '');
Expand Down
7 changes: 6 additions & 1 deletion src/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do you use this env var?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an environment variable that affects JFrog CLI behavior by disabling the new existing version check on each run.
The check is useful for local usage, but in CI it is redundant and can trigger GitHub API rate limits (happened to us)
@MaorEJFrog

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 ?? '');
Expand Down Expand Up @@ -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';
Expand Down
Loading