From d0fdbe2a3e54b07c733bbfc52edb83b53898f635 Mon Sep 17 00:00:00 2001 From: Inaki Villar Date: Tue, 11 Jun 2024 15:55:59 -0700 Subject: [PATCH] adding new develocity inputs variables --- setup-gradle/action.yml | 36 +++++++++++++++++++++++++ sources/src/configuration.ts | 40 ++++++++++++++++++++++++++++ sources/src/develocity/build-scan.ts | 17 ++++++++++++ 3 files changed, 93 insertions(+) diff --git a/setup-gradle/action.yml b/setup-gradle/action.yml index f768c52..cd26fb8 100644 --- a/setup-gradle/action.yml +++ b/setup-gradle/action.yml @@ -108,6 +108,42 @@ inputs: description: The Develocity short-lived access tokens expiry in hours. Default is 2 hours. required: false + develocity-injection-enabled: + description: Enables Develocity injection. + required: false + + develocity-url: + description: The URL for the Develocity server. + required: false + + develocity-allow-untrusted-server: + description: Allow communication with an untrusted server; set to _true_ if your Develocity instance is using a self-signed. + required: false + + develocity-enforce-url: + description: Enforce the configured Develocity URL over a URL configured in the project's build; set to _true_ to enforce publication of build scans to the configured Develocity URL. + required: false + + develocity-plugin-version: + description: The version of the Develocity Gradle plugin to apply. + required: false + + develocity-ccud-plugin-version: + description: The version of the Common Custom User Data Gradle plugin to apply, if any. + required: false + + gradle-plugin-repository-url: + description: The URL of the repository to use when resolving the Develocity and CCUD plugins; the Gradle Plugin Portal is used by default. + required: false + + gradle-plugin-repository-username: + description: The username for the repository URL to use when resolving the Develocity and CCUD. + required: false + + gradle-plugin-repository-password: + description: The password for the repository URL to use when resolving the Develocity and CCUD plugins; Consider using secrets to pass the value to this variable. + required: false + # Wrapper validation configuration validate-wrappers: description: | diff --git a/sources/src/configuration.ts b/sources/src/configuration.ts index ba4552a..378f0ea 100644 --- a/sources/src/configuration.ts +++ b/sources/src/configuration.ts @@ -216,6 +216,46 @@ export class BuildScanConfig { return core.getInput('develocity-token-expiry') } + getDevelocityInjectionEnabled(): string { + return core.getInput('develocity-injection-enabled') + } + + getDevelocityUrl(): string { + return core.getInput('develocity-url') + } + + getDevelocityAllowUntrustedServer(): string { + return core.getInput('develocity-allow-untrusted-server') + } + + getDevelocityCaptureFileFingerprints(): string { + return core.getInput('develocity-capture-file-fingerprints') + } + + getDevelocityEnforceUrl(): string { + return core.getInput('develocity-enforce-url') + } + + getDevelocityPluginVersion(): string { + return core.getInput('develocity-plugin-version') + } + + getDevelocityCcudPluginVersion(): string { + return core.getInput('develocity-ccud-plugin-version') + } + + getGradlePluginRepositoryUrl(): string { + return core.getInput('gradle-plugin-repository-url') + } + + getGradlePluginRepositoryUsername(): string { + return core.getInput('gradle-plugin-repository-username') + } + + getGradlePluginRepositoryPassword(): string { + return core.getInput('gradle-plugin-repository-password') + } + private verifyTermsOfUseAgreement(): boolean { if ( (this.getBuildScanTermsOfUseUrl() !== 'https://gradle.com/terms-of-service' && diff --git a/sources/src/develocity/build-scan.ts b/sources/src/develocity/build-scan.ts index df13690..b381a77 100644 --- a/sources/src/develocity/build-scan.ts +++ b/sources/src/develocity/build-scan.ts @@ -12,6 +12,17 @@ export async function setup(config: BuildScanConfig): Promise { maybeExportVariable('DEVELOCITY_TERMS_OF_USE_URL', config.getBuildScanTermsOfUseUrl()) maybeExportVariable('DEVELOCITY_TERMS_OF_USE_AGREE', config.getBuildScanTermsOfUseAgree()) } + + 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('GRADLE_PLUGIN_REPOSITORY_URL', config.getGradlePluginRepositoryUrl()) + maybeExportVariableNotEmpty('GRADLE_PLUGIN_REPOSITORY_USERNAME', config.getGradlePluginRepositoryUsername()) + maybeExportVariableNotEmpty('GRADLE_PLUGIN_REPOSITORY_PASSWORD', config.getGradlePluginRepositoryPassword()) + setupToken( config.getDevelocityAccessKey(), config.getDevelocityTokenExpiry(), @@ -29,3 +40,9 @@ function maybeExportVariable(variableName: string, value: unknown): void { core.exportVariable(variableName, value) } } + +function maybeExportVariableNotEmpty(variableName: string, value: unknown): void { + if (value !== null && value !== undefined && value !== '') { + maybeExportVariable(variableName, value) + } +}