Skip to content

Commit 5f1c582

Browse files
cdsapbigdaz
authored andcommitted
handle missing access token
1 parent d9336da commit 5f1c582

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

.github/workflows/integ-test-inject-develocity.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ jobs:
155155
id: gradle
156156
working-directory: .github/workflow-samples/no-ge
157157
run: gradle help
158-
- name: Check access key is blank (DEVELOCITY_ACCESS_KEY)
159-
run: "[ \"${DEVELOCITY_ACCESS_KEY}\" == \"\" ] || (echo 'DEVELOCITY_ACCESS_KEY has leaked!'; exit 1)"
158+
- name: Check access key is not blank (DEVELOCITY_ACCESS_KEY)
159+
run: "[ \"${DEVELOCITY_ACCESS_KEY}\" != \"\" ] || (echo 'using DEVELOCITY_ACCESS_KEY!'; exit 1)"
160160
- name: Check access key is not blank (GRADLE_ENTERPRISE_ACCESS_KEY)
161161
run: "[ \"${GRADLE_ENTERPRISE_ACCESS_KEY}\" != \"\" ] || (echo 'GRADLE_ENTERPRISE_ACCESS_KEY is still supported in v3!'; exit 1)"
162162

sources/src/develocity/short-lived-token.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ export async function setupToken(
1919
core.setSecret(token)
2020
exportAccessKeyEnvVars(token)
2121
} else {
22-
// In case of not being able to generate a token we set the env variable to empty to avoid leaks
23-
clearAccessKeyEnvVarsWithDeprecationWarning()
22+
handleMissingAccessTokenWithDeprecationWarning()
2423
}
2524
} catch (e) {
26-
clearAccessKeyEnvVarsWithDeprecationWarning()
25+
handleMissingAccessTokenWithDeprecationWarning()
2726
core.warning(`Failed to fetch short-lived token, reason: ${e}`)
2827
}
2928
}
@@ -35,12 +34,14 @@ function exportAccessKeyEnvVars(value: string): void {
3534
)
3635
}
3736

38-
function clearAccessKeyEnvVarsWithDeprecationWarning(): void {
37+
function handleMissingAccessTokenWithDeprecationWarning(): void {
3938
if (process.env[BuildScanConfig.GradleEnterpriseAccessKeyEnvVar]) {
4039
// We do not clear the GRADLE_ENTERPRISE_ACCESS_KEY env var in v3, to let the users upgrade to DV 2024.1
4140
recordDeprecation(`The ${BuildScanConfig.GradleEnterpriseAccessKeyEnvVar} env var is deprecated`)
4241
}
43-
core.exportVariable(BuildScanConfig.DevelocityAccessKeyEnvVar, '')
42+
if (process.env[BuildScanConfig.DevelocityAccessKeyEnvVar]) {
43+
core.warning(`Failed to fetch short-lived token, using Develocity Access key`)
44+
}
4445
}
4546

4647
export async function getToken(

0 commit comments

Comments
 (0)