mirror of
https://github.com/gradle/actions.git
synced 2025-04-23 03:09:20 +08:00
Do not clear GRADLE_ENTERPRISE_ACCESS_KEY
env var and output a deprecation warning
This commit is contained in:
parent
18bd508bcf
commit
245e8e6b91
@ -157,5 +157,5 @@ jobs:
|
|||||||
run: gradle help
|
run: gradle help
|
||||||
- name: Check access key is blank (DEVELOCITY_ACCESS_KEY)
|
- name: Check access key is blank (DEVELOCITY_ACCESS_KEY)
|
||||||
run: "[ \"${DEVELOCITY_ACCESS_KEY}\" == \"\" ] || (echo 'DEVELOCITY_ACCESS_KEY has leaked!'; exit 1)"
|
run: "[ \"${DEVELOCITY_ACCESS_KEY}\" == \"\" ] || (echo 'DEVELOCITY_ACCESS_KEY has leaked!'; exit 1)"
|
||||||
- name: Check access key is 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 has leaked!'; exit 1)"
|
run: "[ \"${GRADLE_ENTERPRISE_ACCESS_KEY}\" != \"\" ] || (echo 'GRADLE_ENTERPRISE_ACCESS_KEY is still supported in v3!'; exit 1)"
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# Deprecation upgrade guide
|
# Deprecation upgrade guide
|
||||||
|
|
||||||
As these actions evolve, certain inputs, behaviour and usages are deprecated for removal.
|
As these actions evolve, certain inputs, behaviour and usages are deprecated for removal.
|
||||||
Deprecated functionality will be fully supported during the current major release, and will be
|
Deprecated functionality will be fully supported during the current major release, and will be
|
||||||
removed in the next major release.
|
removed in the next major release.
|
||||||
Users will receive a deprecation warning when they rely on deprecated functionality,
|
Users will receive a deprecation warning when they rely on deprecated functionality,
|
||||||
prompting them to update their workflows.
|
prompting them to update their workflows.
|
||||||
|
|
||||||
## The action `gradle/gradle-build-action` has been replaced by `gradle/actions/setup-gradle`
|
## The action `gradle/gradle-build-action` has been replaced by `gradle/actions/setup-gradle`
|
||||||
@ -25,10 +25,10 @@ with
|
|||||||
|
|
||||||
## The action `gradle/wrapper-validation-action` has been replaced by `gradle/actions/wrapper-validation`
|
## The action `gradle/wrapper-validation-action` has been replaced by `gradle/actions/wrapper-validation`
|
||||||
|
|
||||||
To facilitate ongoing development, the `wrapper-validation-action` action implementation has been merged into
|
To facilitate ongoing development, the `wrapper-validation-action` action implementation has been merged into
|
||||||
the https://github.com/gradle/actions repository, and the `gradle/wrapper-validation-action` has been replaced by the `gradle/actions/wrapper-validation` action.
|
the https://github.com/gradle/actions repository, and the `gradle/wrapper-validation-action` has been replaced by the `gradle/actions/wrapper-validation` action.
|
||||||
|
|
||||||
As of `v3.x`, the `gradle/wrapper-validation-action` and `gradle/actions/wrappper-validation` actions are
|
As of `v3.x`, the `gradle/wrapper-validation-action` and `gradle/actions/wrappper-validation` actions are
|
||||||
functionally identical, and are released with the same versions.
|
functionally identical, and are released with the same versions.
|
||||||
|
|
||||||
In a future major version (likely `v4.x`) we will stop releasing new versions of `gradle/wrapper-validation-action`:
|
In a future major version (likely `v4.x`) we will stop releasing new versions of `gradle/wrapper-validation-action`:
|
||||||
@ -143,3 +143,8 @@ to this:
|
|||||||
build-scan-terms-of-use-agree: "yes"
|
build-scan-terms-of-use-agree: "yes"
|
||||||
```
|
```
|
||||||
These deprecated build-scan parameters are scheduled to be removed in `setup-gradle@v4` and `dependency-submission@v4`.
|
These deprecated build-scan parameters are scheduled to be removed in `setup-gradle@v4` and `dependency-submission@v4`.
|
||||||
|
|
||||||
|
## The GRADLE_ENTERPRISE_ACCESS_KEY env var is deprecated
|
||||||
|
Gradle Enterprise has been renamed to Develocity starting from Gradle plugin 3.17 and Develocity server 2024.1.
|
||||||
|
In v4 release of the action, it will require setting the access key with the `develocity-access-key` input and Develocity 2024.1 at least to generate short-lived tokens.
|
||||||
|
If those requirements are not met, the `GRADLE_ENTERPRISE_ACCESS_KEY` env var will be cleared out and build scan publication or other authenticated Develocity operations won't be possible.
|
||||||
|
@ -747,8 +747,9 @@ This access key will be used during the action execution to get a short-lived to
|
|||||||
|
|
||||||
### Short-lived access tokens
|
### Short-lived access tokens
|
||||||
Develocity access keys are long-lived, creating risks if they are leaked. To avoid this, users can use short-lived access tokens to authenticate with Develocity. Access tokens can be used wherever an access key would be used. Access tokens are only valid for the Develocity instance that created them.
|
Develocity access keys are long-lived, creating risks if they are leaked. To avoid this, users can use short-lived access tokens to authenticate with Develocity. Access tokens can be used wherever an access key would be used. Access tokens are only valid for the Develocity instance that created them.
|
||||||
If a short-lived token fails to be retrieved (for example, if the Develocity server version is lower than `2024.1`), no access key will be set.
|
If a short-lived token fails to be retrieved (for example, if the Develocity server version is lower than `2024.1`):
|
||||||
In that case, Develocity authenticated operations like build cache read/write and build scan publication will fail without failing the build.
|
- if a `GRADLE_ENTERPRISE_ACCESS_KEY` env var has been set, we're falling back to it with a deprecation warning
|
||||||
|
- otherwise no access key env var will be set. In that case Develocity authenticated operations like build cache read/write and build scan publication will fail without failing the build.
|
||||||
For more information on short-lived tokens, see [Develocity API documentation](https://docs.gradle.com/develocity/api-manual/#short_lived_access_tokens).
|
For more information on short-lived tokens, see [Develocity API documentation](https://docs.gradle.com/develocity/api-manual/#short_lived_access_tokens).
|
||||||
|
|
||||||
## Configuring Develocity injection
|
## Configuring Develocity injection
|
||||||
|
@ -188,6 +188,9 @@ export enum JobSummaryOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class BuildScanConfig {
|
export class BuildScanConfig {
|
||||||
|
static DevelocityAccessKeyEnvVar = 'DEVELOCITY_ACCESS_KEY'
|
||||||
|
static GradleEnterpriseAccessKeyEnvVar = 'GRADLE_ENTERPRISE_ACCESS_KEY'
|
||||||
|
|
||||||
getBuildScanPublishEnabled(): boolean {
|
getBuildScanPublishEnabled(): boolean {
|
||||||
return getBooleanInput('build-scan-publish') && this.verifyTermsOfUseAgreement()
|
return getBooleanInput('build-scan-publish') && this.verifyTermsOfUseAgreement()
|
||||||
}
|
}
|
||||||
@ -203,8 +206,8 @@ export class BuildScanConfig {
|
|||||||
getDevelocityAccessKey(): string {
|
getDevelocityAccessKey(): string {
|
||||||
return (
|
return (
|
||||||
core.getInput('develocity-access-key') ||
|
core.getInput('develocity-access-key') ||
|
||||||
process.env['DEVELOCITY_ACCESS_KEY'] ||
|
process.env[BuildScanConfig.DevelocityAccessKeyEnvVar] ||
|
||||||
process.env['GRADLE_ENTERPRISE_ACCESS_KEY'] ||
|
process.env[BuildScanConfig.GradleEnterpriseAccessKeyEnvVar] ||
|
||||||
''
|
''
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import * as httpm from 'typed-rest-client/HttpClient'
|
import * as httpm from 'typed-rest-client/HttpClient'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import {BuildScanConfig} from '../configuration'
|
||||||
|
import {recordDeprecation} from '../deprecation-collector'
|
||||||
|
|
||||||
export async function setupToken(
|
export async function setupToken(
|
||||||
develocityAccessKey: string,
|
develocityAccessKey: string,
|
||||||
@ -18,17 +20,27 @@ export async function setupToken(
|
|||||||
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
|
// In case of not being able to generate a token we set the env variable to empty to avoid leaks
|
||||||
exportAccessKeyEnvVars('')
|
clearAccessKeyEnvVarsWithDeprecationWarning()
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
exportAccessKeyEnvVars('')
|
clearAccessKeyEnvVarsWithDeprecationWarning()
|
||||||
core.warning(`Failed to fetch short-lived token, reason: ${e}`)
|
core.warning(`Failed to fetch short-lived token, reason: ${e}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportAccessKeyEnvVars(value: string): void {
|
function exportAccessKeyEnvVars(value: string): void {
|
||||||
;['DEVELOCITY_ACCESS_KEY', 'GRADLE_ENTERPRISE_ACCESS_KEY'].forEach(key => core.exportVariable(key, value))
|
;[BuildScanConfig.DevelocityAccessKeyEnvVar, BuildScanConfig.GradleEnterpriseAccessKeyEnvVar].forEach(key =>
|
||||||
|
core.exportVariable(key, value)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearAccessKeyEnvVarsWithDeprecationWarning(): void {
|
||||||
|
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
|
||||||
|
recordDeprecation(`The ${BuildScanConfig.GradleEnterpriseAccessKeyEnvVar} env var is deprecated`)
|
||||||
|
}
|
||||||
|
core.exportVariable(BuildScanConfig.DevelocityAccessKeyEnvVar, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getToken(
|
export async function getToken(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user