Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea committed Nov 11, 2024
1 parent 42b4f2d commit 34fc4c4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 4 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ class Utils {
// Use JF_ENV or the credentials found in the environment variables
return jfrogCredentials;
}
// Used for usage reporting
this.exportVariableIfNotSet("JFROG_CLI_USAGE_CONFIG_OIDC", "TRUE");
if (!jfrogCredentials.jfrogUrl) {
throw new Error(`JF_URL must be provided when oidc-provider-name is specified`);
}
Expand All @@ -77,7 +75,10 @@ class Utils {
throw new Error(`Getting openID Connect JSON web token failed: ${error.message}`);
}
try {
return yield this.getJfrogAccessTokenThroughOidcProtocol(jfrogCredentials, jsonWebToken, oidcProviderName);
jfrogCredentials = yield this.getJfrogAccessTokenThroughOidcProtocol(jfrogCredentials, jsonWebToken, oidcProviderName);
// Export env for usage report after successful OIDC token exchange
this.exportVariableIfNotSet("JFROG_CLI_USAGE_CONFIG_OIDC", "TRUE");
return jfrogCredentials;
}
catch (error) {
throw new Error(`Exchanging JSON web token with an access token failed: ${error.message}`);
Expand Down
5 changes: 3 additions & 2 deletions src/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ async function collectAndPublishBuildInfoIfNeeded() {
// Publish the build info to Artifactory
try {
core.startGroup('Publish the build info to JFrog Artifactory');
// Used for usage reporting
core.exportVariable("JFROG_CLI_USAGE_BUILD_PUBLISHED_AUTO", "TRUE");
// Set the environment variable to indicate that the build has been automatically published.
// This is used by the usage report to track instances of automatic build publication.
core.exportVariable('JFROG_CLI_USAGE_BUILD_PUBLISHED_AUTO', 'TRUE');
await Utils.runCli(['rt', 'build-publish'], { cwd: workingDirectory });
} catch (error) {
core.warning('Failed while attempting to publish the build info to JFrog Artifactory: ' + error);
Expand Down
8 changes: 5 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ export class Utils {
return jfrogCredentials;
}

// Used for usage reporting
this.exportVariableIfNotSet("JFROG_CLI_USAGE_CONFIG_OIDC","TRUE")
if (!jfrogCredentials.jfrogUrl) {
throw new Error(`JF_URL must be provided when oidc-provider-name is specified`);
}
Expand All @@ -98,7 +96,11 @@ export class Utils {
}

try {
return await this.getJfrogAccessTokenThroughOidcProtocol(jfrogCredentials, jsonWebToken, oidcProviderName);
jfrogCredentials = await this.getJfrogAccessTokenThroughOidcProtocol(jfrogCredentials, jsonWebToken, oidcProviderName);
// Set environment variable to track OIDC logins in the usage report.
core.exportVariable('JFROG_CLI_USAGE_BUILD_PUBLISHED_AUTO', 'TRUE');
this.exportVariableIfNotSet('JFROG_CLI_USAGE_CONFIG_OIDC', 'TRUE');
return jfrogCredentials;
} catch (error: any) {
throw new Error(`Exchanging JSON web token with an access token failed: ${error.message}`);
}
Expand Down

0 comments on commit 34fc4c4

Please sign in to comment.