mirror of
https://github.com/gradle/actions
synced 2024-11-23 18:02:13 +00:00
Simplify GE-inject config params (#863)
This commit is contained in:
parent
98d77952ea
commit
ef76a971e2
6 changed files with 47 additions and 49 deletions
4
.github/workflows/ci-full-check.yml
vendored
4
.github/workflows/ci-full-check.yml
vendored
|
@ -45,9 +45,11 @@ jobs:
|
|||
cache-key-prefix: ${{github.run_number}}-
|
||||
|
||||
gradle-enterprise-injection:
|
||||
uses: ./github/workflows/integ-test-inject-gradle-enterprise.yml
|
||||
uses: ./.github/workflows/integ-test-inject-gradle-enterprise.yml
|
||||
with:
|
||||
cache-key-prefix: ${{github.run_number}}-
|
||||
secrets:
|
||||
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GE_SOLUTIONS_ACCESS_TOKEN }}
|
||||
|
||||
provision-gradle-versions:
|
||||
uses: ./.github/workflows/integ-test-provision-gradle-versions.yml
|
||||
|
|
4
.github/workflows/ci-quick-check.yml
vendored
4
.github/workflows/ci-quick-check.yml
vendored
|
@ -73,10 +73,12 @@ jobs:
|
|||
|
||||
gradle-enterprise-injection:
|
||||
needs: build-distribution
|
||||
uses: ./github/workflows/integ-test-inject-gradle-enterprise.yml
|
||||
uses: ./.github/workflows/integ-test-inject-gradle-enterprise.yml
|
||||
with:
|
||||
runner-os: '["ubuntu-latest"]'
|
||||
download-dist: true
|
||||
secrets:
|
||||
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GE_SOLUTIONS_ACCESS_TOKEN }}
|
||||
|
||||
provision-gradle-versions:
|
||||
needs: build-distribution
|
||||
|
|
|
@ -11,16 +11,19 @@ on:
|
|||
download-dist:
|
||||
type: boolean
|
||||
default: false
|
||||
secrets:
|
||||
GRADLE_ENTERPRISE_ACCESS_KEY:
|
||||
required: true
|
||||
|
||||
env:
|
||||
DOWNLOAD_DIST: ${{ inputs.download-dist }}
|
||||
GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX: provision-gradle-versions-${{ inputs.cache-key-prefix }}
|
||||
GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
|
||||
GRADLE_ENTERPRISE_INJECTION_ENABLED: true
|
||||
GRADLE_ENTERPRISE_INJECTION_SERVER_URL: https://ge.solutions-team.gradle.com
|
||||
GRADLE_ENTERPRISE_INJECTION_GE_PLUGIN_VERSION: 3.14.1
|
||||
GRADLE_ENTERPRISE_INJECTION_CCUD_PLUGIN_VERSION: 1.11.1
|
||||
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GE_SOLUTIONS_ACCESS_TOKEN }}
|
||||
GRADLE_ENTERPRISE_URL: https://ge.solutions-team.gradle.com
|
||||
GRADLE_ENTERPRISE_PLUGIN_VERSION: 3.14.1
|
||||
GRADLE_ENTERPRISE_CCUD_PLUGIN_VERSION: 1.11.1
|
||||
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
|
||||
|
||||
jobs:
|
||||
inject-gradle-enterprise:
|
||||
|
|
25
README.md
25
README.md
|
@ -744,8 +744,8 @@ name: Run build with Gradle Enterprise injection
|
|||
|
||||
env:
|
||||
GRADLE_ENTERPRISE_INJECTION_ENABLED: true
|
||||
GRADLE_ENTERPRISE_INJECTION_SERVER_URL: https://ge.gradle.org
|
||||
GRADLE_ENTERPRISE_INJECTION_GE_PLUGIN_VERSION: 3.14.1
|
||||
GRADLE_ENTERPRISE_URL: https://ge.gradle.org
|
||||
GRADLE_ENTERPRISE_PLUGIN_VERSION: 3.14.1
|
||||
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GE_ACCESS_KEY }} # Required to publish scans to ge.gradle.org
|
||||
|
||||
jobs:
|
||||
|
@ -771,18 +771,9 @@ The `init-script` supports a number of additional configuration parameters that
|
|||
| Variable | Required | Description |
|
||||
| --- | --- | --- |
|
||||
| GRADLE_ENTERPRISE_INJECTION_ENABLED | :white_check_mark: | enables Gradle Enterprise injection |
|
||||
| GRADLE_ENTERPRISE_INJECTION_SERVER_URL | :white_check_mark: | the URL of the Gradle Enterprise server |
|
||||
| GRADLE_ENTERPRISE_INJECTION_ALLOW_UNTRUSTED_SERVER | | allow communication with an untrusted server; set to _true_ if your Gradle Enterprise instance is using a self-signed certificate |
|
||||
| GRADLE_ENTERPRISE_INJECTION_ENFORCE_SERVER_URL | | enforce the configured Gradle Enterprise URL over a URL configured in the project's build; set to _true_ to enforce publication of build scans to the configured Gradle Enterprise URL |
|
||||
| GRADLE_ENTERPRISE_INJECTION_GE_PLUGIN_VERSION | :white_check_mark: | the version of the [Gradle Enterprise Gradle plugin](https://docs.gradle.com/enterprise/gradle-plugin/) to apply |
|
||||
| GRADLE_ENTERPRISE_INJECTION_CCUD_PLUGIN_VERSION | | the version of the [Common Custom User Data Gradle plugin](https://github.com/gradle/common-custom-user-data-gradle-plugin) to apply, if any |
|
||||
| GRADLE_ENTERPRISE_INJECTION_PLUGIN_REPOSITORY_URL | | the URL of the repository to use when resolving the GE and CCUD plugins; the Gradle Plugin Portal is used by default |
|
||||
|
||||
## Authentication
|
||||
To authenticate against the Gradle Enterprise server, you will need to define an environment variable named `GRADLE_ENTERPRISE_ACCESS_KEY`.
|
||||
This is not required directly by the Gradle Enterprise injection, but will be required by the Gradle Enterprise Gradle Plugin when connecting to the server.
|
||||
|
||||
To do this, define a [GitHub Actions secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets) at the repository or organization level, and reference this as an environment variable in your workflow file.
|
||||
See the [minimal example above](#enabling-gradle-enterprise-injection) for the syntax.
|
||||
|
||||
To generate a Gradle Enterprise Access Key, refer to the [docs for the Gradle Enterprise Gradle plugin](https://docs.gradle.com/enterprise/gradle-plugin/#manual_access_key_configuration).
|
||||
| GRADLE_ENTERPRISE_URL | :white_check_mark: | the URL of the Gradle Enterprise server |
|
||||
| GRADLE_ENTERPRISE_ALLOW_UNTRUSTED_SERVER | | allow communication with an untrusted server; set to _true_ if your Gradle Enterprise instance is using a self-signed certificate |
|
||||
| GRADLE_ENTERPRISE_ENFORCE_URL | | enforce the configured Gradle Enterprise URL over a URL configured in the project's build; set to _true_ to enforce publication of build scans to the configured Gradle Enterprise URL |
|
||||
| GRADLE_ENTERPRISE_PLUGIN_VERSION | :white_check_mark: | the version of the [Gradle Enterprise Gradle plugin](https://docs.gradle.com/enterprise/gradle-plugin/) to apply |
|
||||
| GRADLE_ENTERPRISE_CCUD_PLUGIN_VERSION | | the version of the [Common Custom User Data Gradle plugin](https://github.com/gradle/common-custom-user-data-gradle-plugin) to apply, if any |
|
||||
| GRADLE_ENTERPRISE_PLUGIN_REPOSITORY_URL | | the URL of the repository to use when resolving the GE and CCUD plugins; the Gradle Plugin Portal is used by default |
|
||||
|
|
|
@ -15,14 +15,14 @@ initscript {
|
|||
}
|
||||
|
||||
// finish early if injection is disabled
|
||||
def gradleInjectionEnabled = getInputParam("gradle-enterprise-injection.enabled")
|
||||
def gradleInjectionEnabled = getInputParam("gradle-enterprise.injection-enabled")
|
||||
if (gradleInjectionEnabled != "true") {
|
||||
return
|
||||
}
|
||||
|
||||
def pluginRepositoryUrl = getInputParam('gradle-enterprise-injection.plugin-repository-url')
|
||||
def gePluginVersion = getInputParam('gradle-enterprise-injection.ge-plugin-version')
|
||||
def ccudPluginVersion = getInputParam('gradle-enterprise-injection.ccud-plugin-version')
|
||||
def pluginRepositoryUrl = getInputParam('gradle-enterprise.plugin-repository.url')
|
||||
def gePluginVersion = getInputParam('gradle-enterprise.plugin.version')
|
||||
def ccudPluginVersion = getInputParam('gradle-enterprise.ccud-plugin.version')
|
||||
|
||||
def atLeastGradle5 = GradleVersion.current() >= GradleVersion.version('5.0')
|
||||
def atLeastGradle4 = GradleVersion.current() >= GradleVersion.version('4.0')
|
||||
|
@ -71,17 +71,17 @@ def getInputParam = { String name ->
|
|||
}
|
||||
|
||||
// finish early if injection is disabled
|
||||
def gradleInjectionEnabled = getInputParam("gradle-enterprise-injection.enabled")
|
||||
def gradleInjectionEnabled = getInputParam("gradle-enterprise.injection-enabled")
|
||||
if (gradleInjectionEnabled != "true") {
|
||||
return
|
||||
}
|
||||
|
||||
def geUrl = getInputParam('gradle-enterprise-injection.server-url')
|
||||
def geAllowUntrustedServer = Boolean.parseBoolean(getInputParam('gradle-enterprise-injection.allow-untrusted-server'))
|
||||
def geEnforceUrl = Boolean.parseBoolean(getInputParam('gradle-enterprise-injection.enforce-server-url'))
|
||||
def buildScanUploadInBackground = Boolean.parseBoolean(getInputParam('gradle-enterprise-injection.build-scan-upload-in-background'))
|
||||
def gePluginVersion = getInputParam('gradle-enterprise-injection.ge-plugin-version')
|
||||
def ccudPluginVersion = getInputParam('gradle-enterprise-injection.ccud-plugin-version')
|
||||
def geUrl = getInputParam('gradle-enterprise.url')
|
||||
def geAllowUntrustedServer = Boolean.parseBoolean(getInputParam('gradle-enterprise.allow-untrusted-server'))
|
||||
def geEnforceUrl = Boolean.parseBoolean(getInputParam('gradle-enterprise.enforce-url'))
|
||||
def buildScanUploadInBackground = Boolean.parseBoolean(getInputParam('gradle-enterprise.build-scan.upload-in-background'))
|
||||
def gePluginVersion = getInputParam('gradle-enterprise.plugin.version')
|
||||
def ccudPluginVersion = getInputParam('gradle-enterprise.ccud-plugin.version')
|
||||
|
||||
def atLeastGradle4 = GradleVersion.current() >= GradleVersion.version('4.0')
|
||||
|
||||
|
|
|
@ -370,30 +370,30 @@ class TestGradleEnterpriseInjection extends BaseInitScriptTest {
|
|||
def getEnvVars() {
|
||||
Map<String, String> envVars = [
|
||||
GRADLE_ENTERPRISE_INJECTION_ENABLED: "true",
|
||||
GRADLE_ENTERPRISE_INJECTION_SERVER_URL: serverUrl,
|
||||
GRADLE_ENTERPRISE_INJECTION_ALLOW_UNTRUSTED_SERVER: "true",
|
||||
GRADLE_ENTERPRISE_INJECTION_GE_PLUGIN_VERSION: GE_PLUGIN_VERSION,
|
||||
GRADLE_ENTERPRISE_INJECTION_BUILD_SCAN_UPLOAD_IN_BACKGROUND: "true" // Need to upload in background since our Mock server doesn't cope with foreground upload
|
||||
GRADLE_ENTERPRISE_URL: serverUrl,
|
||||
GRADLE_ENTERPRISE_ALLOW_UNTRUSTED_SERVER: "true",
|
||||
GRADLE_ENTERPRISE_PLUGIN_VERSION: GE_PLUGIN_VERSION,
|
||||
GRADLE_ENTERPRISE_BUILD_SCAN_UPLOAD_IN_BACKGROUND: "true" // Need to upload in background since our Mock server doesn't cope with foreground upload
|
||||
]
|
||||
if (enforceUrl) envVars.put("GRADLE_ENTERPRISE_INJECTION_ENFORCE_SERVER_URL", "true")
|
||||
if (ccudPluginVersion != null) envVars.put("GRADLE_ENTERPRISE_INJECTION_CCUD_PLUGIN_VERSION", ccudPluginVersion)
|
||||
if (pluginRepositoryUrl != null) envVars.put("GRADLE_ENTERPRISE_INJECTION_PLUGIN_REPOSITORY_URL", pluginRepositoryUrl)
|
||||
if (enforceUrl) envVars.put("GRADLE_ENTERPRISE_ENFORCE_URL", "true")
|
||||
if (ccudPluginVersion != null) envVars.put("GRADLE_ENTERPRISE_CCUD_PLUGIN_VERSION", ccudPluginVersion)
|
||||
if (pluginRepositoryUrl != null) envVars.put("GRADLE_ENTERPRISE_PLUGIN_REPOSITORY_URL", pluginRepositoryUrl)
|
||||
|
||||
return envVars
|
||||
}
|
||||
|
||||
def getJvmArgs() {
|
||||
List<String> jvmArgs = [
|
||||
"-Dgradle-enterprise-injection.enabled=true",
|
||||
"-Dgradle-enterprise-injection.server-url=$serverUrl",
|
||||
"-Dgradle-enterprise-injection.allow-untrusted-server=true",
|
||||
"-Dgradle-enterprise-injection.ge-plugin-version=$GE_PLUGIN_VERSION",
|
||||
"-Dgradle-enterprise-injection.build-scan-upload-in-background=true"
|
||||
"-Dgradle-enterprise.injection-enabled=true",
|
||||
"-Dgradle-enterprise.url=$serverUrl",
|
||||
"-Dgradle-enterprise.allow-untrusted-server=true",
|
||||
"-Dgradle-enterprise.plugin.version=$GE_PLUGIN_VERSION",
|
||||
"-Dgradle-enterprise.build-scan.upload-in-background=true"
|
||||
]
|
||||
|
||||
if (enforceUrl) jvmArgs.add("-Dgradle-enterprise-injection.enforce-server-url=true")
|
||||
if (ccudPluginVersion != null) jvmArgs.add("-Dgradle-enterprise-injection.ccud-plugin-version=$ccudPluginVersion")
|
||||
if (pluginRepositoryUrl != null) jvmArgs.add("-Dgradle-enterprise-injection.plugin-repository-url=$pluginRepositoryUrl")
|
||||
if (enforceUrl) jvmArgs.add("-Dgradle-enterprise.enforce-url=true")
|
||||
if (ccudPluginVersion != null) jvmArgs.add("-Dgradle-enterprise.ccud-plugin.version=$ccudPluginVersion")
|
||||
if (pluginRepositoryUrl != null) jvmArgs.add("-Dgradle-enterprise.plugin-repository.url=$pluginRepositoryUrl")
|
||||
|
||||
return jvmArgs.collect { it.toString() } // Convert from GStrings
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue