Adapt to changed parameter names in DV injection script

This commit is contained in:
daz 2025-04-04 13:22:21 -06:00
parent 8149a2ab96
commit 8eb3291baf
No known key found for this signature in database
4 changed files with 76 additions and 64 deletions

View File

@ -27,9 +27,9 @@ jobs:
inject-develocity:
env:
DEVELOCITY_INJECTION_ENABLED: true
DEVELOCITY_URL: https://ge.solutions-team.gradle.com
DEVELOCITY_PLUGIN_VERSION: ${{ matrix.plugin-version }}
DEVELOCITY_CCUD_PLUGIN_VERSION: '2.1'
DEVELOCITY_INJECTION_URL: https://ge.solutions-team.gradle.com
DEVELOCITY_INJECTION_DEVELOCITY_PLUGIN_VERSION: ${{ matrix.plugin-version }}
DEVELOCITY_INJECTION_CCUD_PLUGIN_VERSION: '2.1'
${{matrix.accessKeyEnv}}: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
strategy:
fail-fast: false
@ -74,9 +74,9 @@ jobs:
inject-develocity-with-access-key:
env:
DEVELOCITY_INJECTION_ENABLED: true
DEVELOCITY_URL: 'https://ge.solutions-team.gradle.com'
DEVELOCITY_PLUGIN_VERSION: ${{ matrix.plugin-version }}
DEVELOCITY_CCUD_PLUGIN_VERSION: '2.1'
DEVELOCITY_INJECTION_URL: 'https://ge.solutions-team.gradle.com'
DEVELOCITY_INJECTION_DEVELOCITY_PLUGIN_VERSION: ${{ matrix.plugin-version }}
DEVELOCITY_INJECTION_CCUD_PLUGIN_VERSION: '2.1'
strategy:
fail-fast: false
matrix:
@ -115,9 +115,9 @@ jobs:
inject-develocity-short-lived-token-failed:
env:
DEVELOCITY_INJECTION_ENABLED: true
DEVELOCITY_URL: 'https://localhost:3333/'
DEVELOCITY_PLUGIN_VERSION: ${{ matrix.plugin-version }}
DEVELOCITY_CCUD_PLUGIN_VERSION: '2.1'
DEVELOCITY_INJECTION_URL: 'https://localhost:3333/'
DEVELOCITY_INJECTION_DEVELOCITY_PLUGIN_VERSION: ${{ matrix.plugin-version }}
DEVELOCITY_INJECTION_CCUD_PLUGIN_VERSION: '2.1'
# Access key also set as an env var, we want to check it does not leak
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}

View File

@ -870,7 +870,7 @@ This access key will be used during the action execution to get a short-lived to
The `init-script` supports several additional configuration parameters that you may find useful. All configuration options (required and optional) are detailed below:
| Variable | Required | Description |
|--------------------------------------| --- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|--------------------------------------| :---: |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| develocity-injection-enabled | :white_check_mark: | enables Develocity injection |
| develocity-url | :white_check_mark: | the URL of the Develocity server |
| develocity-allow-untrusted-server | | allow communication with an untrusted server; set to _true_ if your Develocity instance is using a self-signed certificate |
@ -884,18 +884,18 @@ The `init-script` supports several additional configuration parameters that you
The input parameters can be expressed as environment variables following the relationships outlined in the table below:
| Input | Environment Variable |
|--------------------------------------|--------------------------------------|
| develocity-injection-enabled | DEVELOCITY_INJECTION_ENABLED |
| develocity-url | DEVELOCITY_URL |
| develocity-allow-untrusted-server | DEVELOCITY_ALLOW_UNTRUSTED_SERVER |
| develocity-capture-file-fingerprints | DEVELOCITY_CAPTURE_FILE_FINGERPRINTS |
| develocity-enforce-url | DEVELOCITY_ENFORCE_URL |
| develocity-plugin-version | DEVELOCITY_PLUGIN_VERSION |
| develocity-ccud-plugin-version | DEVELOCITY_CCUD_PLUGIN_VERSION |
| gradle-plugin-repository-url | GRADLE_PLUGIN_REPOSITORY_URL |
| gradle-plugin-repository-username | GRADLE_PLUGIN_REPOSITORY_USERNAME |
| gradle-plugin-repository-password | GRADLE_PLUGIN_REPOSITORY_PASSWORD |
| Input | Environment Variable |
|--------------------------------------|------------------------------------------------|
| develocity-injection-enabled | DEVELOCITY_INJECTION_ENABLED |
| develocity-url | DEVELOCITY_INJECTION_URL |
| develocity-enforce-url | DEVELOCITY_INJECTION_ENFORCE_URL |
| develocity-allow-untrusted-server | DEVELOCITY_INJECTION_ALLOW_UNTRUSTED_SERVER |
| develocity-capture-file-fingerprints | DEVELOCITY_INJECTION_CAPTURE_FILE_FINGERPRINTS |
| develocity-plugin-version | DEVELOCITY_INJECTION_DEVELOCITY_PLUGIN_VERSION |
| develocity-ccud-plugin-version | DEVELOCITY_INJECTION_CCUD_PLUGIN_VERSION |
| gradle-plugin-repository-url | DEVELOCITY_INJECTION_PLUGIN_REPOSITORY_URL |
| gradle-plugin-repository-username | DEVELOCITY_INJECTION_PLUGIN_REPOSITORY_USERNAME|
| gradle-plugin-repository-password | DEVELOCITY_INJECTION_PLUGIN_REPOSITORY_PASSWORD|
Here's an example using the env vars:

View File

@ -4,28 +4,40 @@ import {setupToken} from './short-lived-token'
export async function setup(config: BuildScanConfig): Promise<void> {
maybeExportVariable('DEVELOCITY_INJECTION_INIT_SCRIPT_NAME', 'gradle-actions.inject-develocity.init.gradle')
maybeExportVariable('DEVELOCITY_AUTO_INJECTION_CUSTOM_VALUE', 'gradle-actions')
maybeExportVariable('DEVELOCITY_INJECTION_CUSTOM_VALUE', 'gradle-actions')
maybeExportVariableNotEmpty('DEVELOCITY_INJECTION_ENABLED', config.getDevelocityInjectionEnabled())
maybeExportVariableNotEmpty('DEVELOCITY_URL', config.getDevelocityUrl())
maybeExportVariableNotEmpty('DEVELOCITY_ALLOW_UNTRUSTED_SERVER', config.getDevelocityAllowUntrustedServer())
maybeExportVariableNotEmpty('DEVELOCITY_CAPTURE_FILE_FINGERPRINTS', config.getDevelocityCaptureFileFingerprints())
maybeExportVariableNotEmpty('DEVELOCITY_ENFORCE_URL', config.getDevelocityEnforceUrl())
maybeExportVariableNotEmpty('DEVELOCITY_PLUGIN_VERSION', config.getDevelocityPluginVersion())
maybeExportVariableNotEmpty('DEVELOCITY_CCUD_PLUGIN_VERSION', config.getDevelocityCcudPluginVersion())
maybeExportVariableNotEmpty('GRADLE_PLUGIN_REPOSITORY_URL', config.getGradlePluginRepositoryUrl())
maybeExportVariableNotEmpty('GRADLE_PLUGIN_REPOSITORY_USERNAME', config.getGradlePluginRepositoryUsername())
maybeExportVariableNotEmpty('GRADLE_PLUGIN_REPOSITORY_PASSWORD', config.getGradlePluginRepositoryPassword())
maybeExportVariableNotEmpty('DEVELOCITY_INJECTION_URL', config.getDevelocityUrl())
maybeExportVariableNotEmpty(
'DEVELOCITY_INJECTION_ALLOW_UNTRUSTED_SERVER',
config.getDevelocityAllowUntrustedServer()
)
maybeExportVariableNotEmpty(
'DEVELOCITY_INJECTION_CAPTURE_FILE_FINGERPRINTS',
config.getDevelocityCaptureFileFingerprints()
)
maybeExportVariableNotEmpty('DEVELOCITY_INJECTION_ENFORCE_URL', config.getDevelocityEnforceUrl())
maybeExportVariableNotEmpty('DEVELOCITY_INJECTION_DEVELOCITY_PLUGIN_VERSION', config.getDevelocityPluginVersion())
maybeExportVariableNotEmpty('DEVELOCITY_INJECTION_CCUD_PLUGIN_VERSION', config.getDevelocityCcudPluginVersion())
maybeExportVariableNotEmpty('DEVELOCITY_INJECTION__PLUGIN_REPOSITORY_URL', config.getGradlePluginRepositoryUrl())
maybeExportVariableNotEmpty(
'DEVELOCITY_INJECTION__PLUGIN_REPOSITORY_USERNAME',
config.getGradlePluginRepositoryUsername()
)
maybeExportVariableNotEmpty(
'DEVELOCITY_INJECTION__PLUGIN_REPOSITORY_PASSWORD',
config.getGradlePluginRepositoryPassword()
)
// If build-scan-publish is enabled, ensure the environment variables are set
// The DEVELOCITY_PLUGIN_VERSION and DEVELOCITY_CCUD_PLUGIN_VERSION are set to the latest versions
// except if they are defined in the configuration
if (config.getBuildScanPublishEnabled()) {
maybeExportVariable('DEVELOCITY_INJECTION_ENABLED', 'true')
maybeExportVariable('DEVELOCITY_PLUGIN_VERSION', '3.19.2')
maybeExportVariable('DEVELOCITY_CCUD_PLUGIN_VERSION', '2.1')
maybeExportVariable('DEVELOCITY_TERMS_OF_USE_URL', config.getBuildScanTermsOfUseUrl())
maybeExportVariable('DEVELOCITY_TERMS_OF_USE_AGREE', config.getBuildScanTermsOfUseAgree())
maybeExportVariable('DEVELOCITY_INJECTION_DEVELOCITY_PLUGIN_VERSION', '3.19.2')
maybeExportVariable('DEVELOCITY_INJECTION_CCUD_PLUGIN_VERSION', '2.1')
maybeExportVariable('DEVELOCITY_INJECTION_TERMS_OF_USE_URL', config.getBuildScanTermsOfUseUrl())
maybeExportVariable('DEVELOCITY_INJECTION_TERMS_OF_USE_AGREE', config.getBuildScanTermsOfUseAgree())
}
return setupToken(

View File

@ -490,43 +490,43 @@ class TestDevelocityInjection extends BaseInitScriptTest {
def getEnvVars() {
Map<String, String> envVars = [
DEVELOCITY_INJECTION_INIT_SCRIPT_NAME : "gradle-actions.inject-develocity.init.gradle",
DEVELOCITY_INJECTION_ENABLED : "true",
DEVELOCITY_URL : serverUrl,
DEVELOCITY_ALLOW_UNTRUSTED_SERVER : "true",
DEVELOCITY_PLUGIN_VERSION : develocityPluginVersion,
DEVELOCITY_BUILD_SCAN_UPLOAD_IN_BACKGROUND: "true", // Need to upload in background since our Mock server doesn't cope with foreground upload
DEVELOCITY_AUTO_INJECTION_CUSTOM_VALUE : 'gradle-actions',
DEVELOCITY_INJECTION_DEBUG : "true"
DEVELOCITY_INJECTION_INIT_SCRIPT_NAME : "gradle-actions.inject-develocity.init.gradle",
DEVELOCITY_INJECTION_ENABLED : "true",
DEVELOCITY_INJECTION_URL : serverUrl,
DEVELOCITY_INJECTION_ALLOW_UNTRUSTED_SERVER : "true",
DEVELOCITY_INJECTION_DEVELOCITY_PLUGIN_VERSION: develocityPluginVersion,
DEVELOCITY_INJECTION_UPLOAD_IN_BACKGROUND : "true", // Need to upload in background since our Mock server doesn't cope with foreground upload
DEVELOCITY_INJECTION_CUSTOM_VALUE : 'gradle-actions',
DEVELOCITY_INJECTION_DEBUG : "true"
]
if (enforceUrl) envVars.put("DEVELOCITY_ENFORCE_URL", "true")
if (ccudPluginVersion != null) envVars.put("DEVELOCITY_CCUD_PLUGIN_VERSION", ccudPluginVersion)
if (pluginRepositoryUrl != null) envVars.put("GRADLE_PLUGIN_REPOSITORY_URL", pluginRepositoryUrl)
if (pluginRepositoryUsername != null) envVars.put("GRADLE_PLUGIN_REPOSITORY_USERNAME", pluginRepositoryUsername)
if (pluginRepositoryPassword != null) envVars.put("GRADLE_PLUGIN_REPOSITORY_PASSWORD", pluginRepositoryPassword)
if (captureFileFingerprints) envVars.put("DEVELOCITY_CAPTURE_FILE_FINGERPRINTS", "true")
if (enforceUrl) envVars.put("DEVELOCITY_INJECTION_ENFORCE_URL", "true")
if (ccudPluginVersion != null) envVars.put("DEVELOCITY_INJECTION_CCUD_PLUGIN_VERSION", ccudPluginVersion)
if (captureFileFingerprints) envVars.put("DEVELOCITY_INJECTION_CAPTURE_FILE_FINGERPRINTS", "true")
if (pluginRepositoryUrl != null) envVars.put("DEVELOCITY_INJECTION_PLUGIN_REPOSITORY_URL", pluginRepositoryUrl)
if (pluginRepositoryUsername != null) envVars.put("DEVELOCITY_INJECTION_PLUGIN_REPOSITORY_USERNAME", pluginRepositoryUsername)
if (pluginRepositoryPassword != null) envVars.put("DEVELOCITY_INJECTION_PLUGIN_REPOSITORY_PASSWORD", pluginRepositoryPassword)
return envVars
}
def getJvmArgs() {
List<String> jvmArgs = [
"-Ddevelocity.injection.init-script-name=gradle-actions.inject-develocity.init.gradle",
"-Ddevelocity.injection-enabled=true",
"-Ddevelocity.url=$serverUrl",
"-Ddevelocity.allow-untrusted-server=true",
"-Ddevelocity.plugin.version=$develocityPluginVersion",
"-Ddevelocity.build-scan.upload-in-background=true",
"-Ddevelocity.auto-injection.custom-value=gradle-actions",
"-Ddevelocity.injection.debug=true"
"-Ddevelocity-injection.init-script-name=gradle-actions.inject-develocity.init.gradle",
"-Ddevelocity-injection.enabled=true",
"-Ddevelocity-injection.url=$serverUrl",
"-Ddevelocity-injection.allow-untrusted-server=true",
"-Ddevelocity-injection.develocity-plugin.version=$develocityPluginVersion",
"-Ddevelocity-injection.upload-in-background=true",
"-Ddevelocity-injection.custom-value=gradle-actions",
"-Ddevelocity-injection.debug=true"
]
if (enforceUrl) jvmArgs.add("-Ddevelocity.enforce-url=true")
if (ccudPluginVersion != null) jvmArgs.add("-Ddevelocity.ccud-plugin.version=$ccudPluginVersion")
if (pluginRepositoryUrl != null) jvmArgs.add("-Dgradle.plugin-repository.url=$pluginRepositoryUrl")
if (pluginRepositoryUsername != null) jvmArgs.add("-Dgradle.plugin-repository.username=$pluginRepositoryUsername")
if (pluginRepositoryPassword != null) jvmArgs.add("-Dgradle.plugin-repository.password=$pluginRepositoryPassword")
if (captureFileFingerprints) jvmArgs.add("-Ddevelocity.capture-file-fingerprints=true")
if (enforceUrl) jvmArgs.add("-Ddevelocity-injection.enforce-url=true")
if (ccudPluginVersion != null) jvmArgs.add("-Ddevelocity-injection.ccud-plugin.version=$ccudPluginVersion")
if (captureFileFingerprints) jvmArgs.add("-Ddevelocity-injection.capture-file-fingerprints=true")
if (pluginRepositoryUrl != null) jvmArgs.add("-Ddevelocity-injection.plugin-repository.url=$pluginRepositoryUrl")
if (pluginRepositoryUsername != null) jvmArgs.add("-Ddevelocity-injection.plugin-repository.username=$pluginRepositoryUsername")
if (pluginRepositoryPassword != null) jvmArgs.add("-Ddevelocity-injection.plugin-repository.password=$pluginRepositoryPassword")
return jvmArgs.collect { it.toString() } // Convert from GStrings
}