Skip to content

Commit 81eeb79

Browse files
committed
export vars
1 parent 88389c9 commit 81eeb79

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

lib/evidence-collection.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,19 @@ function getEvidenceConfiguration() {
116116
}
117117
catch (error) {
118118
core.warning(`Failed to get evidence configuration (network error or server unavailable): ${error}`);
119-
return {external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0};
119+
return { external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0 };
120120
}
121121
if (response.message.statusCode !== 200) {
122122
core.warning(`Failed to get evidence configuration. Status: ${response.message.statusCode}, Response: ${body}`);
123-
return {external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0};
123+
return { external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0 };
124124
}
125125
try {
126126
const config = JSON.parse(body);
127127
return config;
128128
}
129129
catch (error) {
130130
core.warning(`Failed to parse evidence config response: ${error}`);
131-
return {external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0};
131+
return { external_evidence_collection_supported: false, evidence_file_size_limit_mb: 0 };
132132
}
133133
});
134134
}
@@ -164,7 +164,6 @@ function getSigstoreBundlePaths() {
164164
return filePaths;
165165
});
166166
}
167-
168167
/**
169168
* Creates evidence for sigstore bundle files.
170169
* @param maxFileSizeMB Maximum allowed file size in MB

lib/utils.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class Utils {
245245
return Utils.SETUP_JFROG_CLI_SERVER_ID;
246246
}
247247
static setCliEnv() {
248-
var _a, _b, _c, _d, _e;
248+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
249249
Utils.exportVariableIfNotSet('JFROG_CLI_ENV_EXCLUDE', '*password*;*secret*;*key*;*token*;*auth*;JF_ARTIFACTORY_*;JF_ENV_*;JF_URL;JF_USER;JF_PASSWORD;JF_ACCESS_TOKEN');
250250
Utils.exportVariableIfNotSet('JFROG_CLI_OFFER_CONFIG', 'false');
251251
Utils.exportVariableIfNotSet('CI', 'true');
@@ -274,6 +274,14 @@ class Utils {
274274
}
275275
// Indicate if JF_GIT_TOKEN is provided as an environment variable, used by Xray usage.
276276
Utils.exportVariableIfNotSet('JFROG_CLI_USAGE_GH_TOKEN_FOR_CODE_SCANNING_ALERTS_PROVIDED', (_e = process.env.JF_GIT_TOKEN) !== null && _e !== void 0 ? _e : '');
277+
Utils.exportVariableIfNotSet('JFROG_CLI_CI_VCS_REVISION', (_g = (_f = process.env.GITHUB_SHA) !== null && _f !== void 0 ? _f : '') !== null && _g !== void 0 ? _g : '');
278+
Utils.exportVariableIfNotSet('JFROG_CLI_CI_BRANCH', (_j = (_h = process.env.GITHUB_REF_NAME) !== null && _h !== void 0 ? _h : '') !== null && _j !== void 0 ? _j : '');
279+
Utils.exportVariableIfNotSet('JFROG_CLI_CI_VCS_URL', Utils.buildVcsUrl());
280+
}
281+
static buildVcsUrl() {
282+
const serverUrl = process.env.GITHUB_SERVER_URL;
283+
const repo = process.env.GITHUB_REPOSITORY;
284+
return serverUrl && repo ? `${serverUrl}/${repo}` : '';
277285
}
278286
static exportVariableIfNotSet(key, value) {
279287
if (!process.env[key]) {

src/utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,16 @@ export class Utils {
311311

312312
// Indicate if JF_GIT_TOKEN is provided as an environment variable, used by Xray usage.
313313
Utils.exportVariableIfNotSet('JFROG_CLI_USAGE_GH_TOKEN_FOR_CODE_SCANNING_ALERTS_PROVIDED', process.env.JF_GIT_TOKEN ?? '');
314+
315+
Utils.exportVariableIfNotSet('JFROG_CLI_CI_VCS_REVISION', process.env.GITHUB_SHA ?? '' ?? '');
316+
Utils.exportVariableIfNotSet('JFROG_CLI_CI_BRANCH', process.env.GITHUB_REF_NAME ?? '' ?? '');
317+
Utils.exportVariableIfNotSet('JFROG_CLI_CI_VCS_URL', Utils.buildVcsUrl());
318+
}
319+
320+
private static buildVcsUrl(): string {
321+
const serverUrl: string | undefined = process.env.GITHUB_SERVER_URL;
322+
const repo: string | undefined = process.env.GITHUB_REPOSITORY;
323+
return serverUrl && repo ? `${serverUrl}/${repo}` : '';
314324
}
315325

316326
public static exportVariableIfNotSet(key: string, value: string) {

0 commit comments

Comments
 (0)