Skip to content

Commit ffe1649

Browse files
committed
revert
1 parent 2d7316e commit ffe1649

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

lib/oidc-utils.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,33 @@ class OidcUtils {
223223
core.exportVariable('JFROG_CLI_USAGE_OIDC_USED', 'TRUE');
224224
}
225225
static buildOidcTokenExchangePayload(jwt, providerName, applicationKey) {
226-
var _a, _b, _c, _d, _e, _f;
226+
var _a, _b, _c, _d, _e, _f, _g, _h;
227227
return {
228228
grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange',
229229
subject_token_type: 'urn:ietf:params:oauth:token-type:id_token',
230230
subject_token: jwt,
231231
provider_name: providerName,
232232
project_key: (_a = process.env.JF_PROJECT) !== null && _a !== void 0 ? _a : '',
233-
job_id: (_b = process.env.GITHUB_JOB) !== null && _b !== void 0 ? _b : '',
234-
run_id: (_c = process.env.GITHUB_RUN_ID) !== null && _c !== void 0 ? _c : '',
235-
repo: (_d = process.env.GITHUB_REPOSITORY) !== null && _d !== void 0 ? _d : '',
236-
revision: (_e = process.env.GITHUB_SHA) !== null && _e !== void 0 ? _e : '',
237-
branch: (_f = process.env.GITHUB_REF_NAME) !== null && _f !== void 0 ? _f : '',
233+
gh_job_id: (_b = process.env.GITHUB_JOB) !== null && _b !== void 0 ? _b : '',
234+
gh_run_id: (_c = process.env.GITHUB_RUN_ID) !== null && _c !== void 0 ? _c : '',
235+
gh_repo: (_d = process.env.GITHUB_REPOSITORY) !== null && _d !== void 0 ? _d : '',
236+
gh_revision: (_e = process.env.GITHUB_SHA) !== null && _e !== void 0 ? _e : '',
237+
gh_branch: (_f = process.env.GITHUB_REF_NAME) !== null && _f !== void 0 ? _f : '',
238238
application_key: applicationKey,
239+
context: {
240+
vcs_commit: {
241+
vcs_url: this.buildVcsUrl(),
242+
branch: (_g = process.env.GITHUB_REF_NAME) !== null && _g !== void 0 ? _g : '',
243+
revision: (_h = process.env.GITHUB_SHA) !== null && _h !== void 0 ? _h : '',
244+
},
245+
},
239246
};
240247
}
248+
static buildVcsUrl() {
249+
const serverUrl = process.env.GITHUB_SERVER_URL;
250+
const repo = process.env.GITHUB_REPOSITORY;
251+
return serverUrl && repo ? `${serverUrl}/${repo}` : '';
252+
}
241253
/**
242254
* Retrieves the application key from .jfrog/config file.
243255
*

src/oidc-utils.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,28 @@ export class OidcUtils {
218218
subject_token: jwt,
219219
provider_name: providerName,
220220
project_key: process.env.JF_PROJECT ?? '',
221-
job_id: process.env.GITHUB_JOB ?? '',
222-
run_id: process.env.GITHUB_RUN_ID ?? '',
223-
repo: process.env.GITHUB_REPOSITORY ?? '',
224-
revision: process.env.GITHUB_SHA ?? '',
225-
branch: process.env.GITHUB_REF_NAME ?? '',
221+
gh_job_id: process.env.GITHUB_JOB ?? '',
222+
gh_run_id: process.env.GITHUB_RUN_ID ?? '',
223+
gh_repo: process.env.GITHUB_REPOSITORY ?? '',
224+
gh_revision: process.env.GITHUB_SHA ?? '',
225+
gh_branch: process.env.GITHUB_REF_NAME ?? '',
226226
application_key: applicationKey,
227+
context: {
228+
vcs_commit: {
229+
vcs_url: this.buildVcsUrl(),
230+
branch: process.env.GITHUB_REF_NAME ?? '',
231+
revision: process.env.GITHUB_SHA ?? '',
232+
},
233+
},
227234
};
228235
}
229236

237+
private static buildVcsUrl(): string {
238+
const serverUrl: string | undefined = process.env.GITHUB_SERVER_URL;
239+
const repo: string | undefined = process.env.GITHUB_REPOSITORY;
240+
return serverUrl && repo ? `${serverUrl}/${repo}` : '';
241+
}
242+
230243
/**
231244
* Retrieves the application key from .jfrog/config file.
232245
*

0 commit comments

Comments
 (0)