mirror of
https://github.com/gradle/actions.git
synced 2025-08-24 19:01:27 +08:00
handle missing access token
This commit is contained in:
parent
d9336dac04
commit
5f1c5827bf
@ -155,8 +155,8 @@ jobs:
|
|||||||
id: gradle
|
id: gradle
|
||||||
working-directory: .github/workflow-samples/no-ge
|
working-directory: .github/workflow-samples/no-ge
|
||||||
run: gradle help
|
run: gradle help
|
||||||
- name: Check access key is blank (DEVELOCITY_ACCESS_KEY)
|
- name: Check access key is not blank (DEVELOCITY_ACCESS_KEY)
|
||||||
run: "[ \"${DEVELOCITY_ACCESS_KEY}\" == \"\" ] || (echo 'DEVELOCITY_ACCESS_KEY has leaked!'; exit 1)"
|
run: "[ \"${DEVELOCITY_ACCESS_KEY}\" != \"\" ] || (echo 'using DEVELOCITY_ACCESS_KEY!'; exit 1)"
|
||||||
- name: Check access key is not blank (GRADLE_ENTERPRISE_ACCESS_KEY)
|
- name: Check access key is not blank (GRADLE_ENTERPRISE_ACCESS_KEY)
|
||||||
run: "[ \"${GRADLE_ENTERPRISE_ACCESS_KEY}\" != \"\" ] || (echo 'GRADLE_ENTERPRISE_ACCESS_KEY is still supported in v3!'; exit 1)"
|
run: "[ \"${GRADLE_ENTERPRISE_ACCESS_KEY}\" != \"\" ] || (echo 'GRADLE_ENTERPRISE_ACCESS_KEY is still supported in v3!'; exit 1)"
|
||||||
|
|
||||||
|
@ -19,11 +19,10 @@ export async function setupToken(
|
|||||||
core.setSecret(token)
|
core.setSecret(token)
|
||||||
exportAccessKeyEnvVars(token)
|
exportAccessKeyEnvVars(token)
|
||||||
} else {
|
} else {
|
||||||
// In case of not being able to generate a token we set the env variable to empty to avoid leaks
|
handleMissingAccessTokenWithDeprecationWarning()
|
||||||
clearAccessKeyEnvVarsWithDeprecationWarning()
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
clearAccessKeyEnvVarsWithDeprecationWarning()
|
handleMissingAccessTokenWithDeprecationWarning()
|
||||||
core.warning(`Failed to fetch short-lived token, reason: ${e}`)
|
core.warning(`Failed to fetch short-lived token, reason: ${e}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,12 +34,14 @@ function exportAccessKeyEnvVars(value: string): void {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearAccessKeyEnvVarsWithDeprecationWarning(): void {
|
function handleMissingAccessTokenWithDeprecationWarning(): void {
|
||||||
if (process.env[BuildScanConfig.GradleEnterpriseAccessKeyEnvVar]) {
|
if (process.env[BuildScanConfig.GradleEnterpriseAccessKeyEnvVar]) {
|
||||||
// We do not clear the GRADLE_ENTERPRISE_ACCESS_KEY env var in v3, to let the users upgrade to DV 2024.1
|
// We do not clear the GRADLE_ENTERPRISE_ACCESS_KEY env var in v3, to let the users upgrade to DV 2024.1
|
||||||
recordDeprecation(`The ${BuildScanConfig.GradleEnterpriseAccessKeyEnvVar} env var is deprecated`)
|
recordDeprecation(`The ${BuildScanConfig.GradleEnterpriseAccessKeyEnvVar} env var is deprecated`)
|
||||||
}
|
}
|
||||||
core.exportVariable(BuildScanConfig.DevelocityAccessKeyEnvVar, '')
|
if (process.env[BuildScanConfig.DevelocityAccessKeyEnvVar]) {
|
||||||
|
core.warning(`Failed to fetch short-lived token, using Develocity Access key`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getToken(
|
export async function getToken(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user