mirror of
https://github.com/gradle/actions.git
synced 2025-10-17 15:08:37 +08:00
Inject Develocity plugin for versions 3.17 and above (#62)
To handle the rebranding of the GE plugin, this PR updates the inject-develocity init script to apply the `com.gradle.develocity` plugin if `3.17+` version of the plugin is requested.
This commit is contained in:
parent
5512434733
commit
5a171ce5b8
@ -24,13 +24,15 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
DEVELOCITY_INJECTION_ENABLED: true
|
DEVELOCITY_INJECTION_ENABLED: true
|
||||||
DEVELOCITY_URL: https://ge.solutions-team.gradle.com
|
DEVELOCITY_URL: https://ge.solutions-team.gradle.com
|
||||||
DEVELOCITY_PLUGIN_VERSION: 3.16.2
|
DEVELOCITY_PLUGIN_VERSION: ${{ matrix.plugin-version }}
|
||||||
DEVELOCITY_CCUD_PLUGIN_VERSION: 1.13
|
DEVELOCITY_CCUD_PLUGIN_VERSION: 1.13
|
||||||
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} # This env var has not (yet) been renamed/aliased in GE plugin 3.16.2
|
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} # required to test against GE plugin 3.16.2
|
||||||
|
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
gradle: [current, 7.6.2, 6.9.4, 5.6.4]
|
gradle: [current, 7.6.2, 6.9.4, 5.6.4]
|
||||||
os: ${{fromJSON(inputs.runner-os)}}
|
os: ${{fromJSON(inputs.runner-os)}}
|
||||||
|
plugin-version: [3.16.2, 3.17]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
@ -81,8 +83,8 @@ jobs:
|
|||||||
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
cache-read-only: false # For testing, allow writing cache entries on non-default branches
|
||||||
gradle-version: ${{ matrix.gradle }}
|
gradle-version: ${{ matrix.gradle }}
|
||||||
build-scan-publish: true
|
build-scan-publish: true
|
||||||
build-scan-terms-of-service-url: "https://gradle.com/terms-of-service"
|
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
|
||||||
build-scan-terms-of-service-agree: "yes"
|
build-scan-terms-of-use-agree: "yes"
|
||||||
- name: Run Gradle build
|
- name: Run Gradle build
|
||||||
id: gradle
|
id: gradle
|
||||||
working-directory: .github/workflow-samples/no-ge
|
working-directory: .github/workflow-samples/no-ge
|
||||||
|
@ -97,15 +97,15 @@ offending dependency.
|
|||||||
### Publishing a Develocity Build Scan® from your dependency submission workflow
|
### Publishing a Develocity Build Scan® from your dependency submission workflow
|
||||||
|
|
||||||
You can automatically publish a Build Scan on every run of `gradle/actions/dependency-submission`. Three input parameters are
|
You can automatically publish a Build Scan on every run of `gradle/actions/dependency-submission`. Three input parameters are
|
||||||
required, one to enable publishing and two more to accept the [Develocity terms of service](https://gradle.com/terms-of-service).
|
required, one to enable publishing and two more to accept the [Develocity terms of use](https://gradle.com/help/legal-terms-of-use).
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Generate and submit dependency graph
|
- name: Generate and submit dependency graph
|
||||||
uses: gradle/actions/dependency-submission@v3
|
uses: gradle/actions/dependency-submission@v3
|
||||||
with:
|
with:
|
||||||
build-scan-publish: true
|
build-scan-publish: true
|
||||||
build-scan-terms-of-service-url: "https://gradle.com/terms-of-service"
|
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
|
||||||
build-scan-terms-of-service-agree: "yes"
|
build-scan-terms-of-use-agree: "yes"
|
||||||
```
|
```
|
||||||
|
|
||||||
### When you cannot publish a Build Scan®
|
### When you cannot publish a Build Scan®
|
||||||
|
@ -37,14 +37,14 @@ inputs:
|
|||||||
build-scan-publish:
|
build-scan-publish:
|
||||||
description: |
|
description: |
|
||||||
Set to 'true' to automatically publish build results as a Build Scan on scans.gradle.com.
|
Set to 'true' to automatically publish build results as a Build Scan on scans.gradle.com.
|
||||||
For publication to succeed without user input, you must also provide values for `build-scan-terms-of-service-url` and 'build-scan-terms-of-service-agree'.
|
For publication to succeed without user input, you must also provide values for `build-scan-terms-of-use-url` and 'build-scan-terms-of-use-agree'.
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
build-scan-terms-of-service-url:
|
build-scan-terms-of-use-url:
|
||||||
description: The URL to the Build Scan® terms of service. This input must be set to 'https://gradle.com/terms-of-service'.
|
description: The URL to the Build Scan® terms of use. This input must be set to 'https://gradle.com/help/legal-terms-of-use'.
|
||||||
required: false
|
required: false
|
||||||
build-scan-terms-of-service-agree:
|
build-scan-terms-of-use-agree:
|
||||||
description: Indicate that you agree to the Build Scan® terms of service. This input value must be "yes".
|
description: Indicate that you agree to the Build Scan® terms of use. This input value must be "yes".
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
@ -67,8 +67,8 @@ runs:
|
|||||||
build-root-directory: ${{ inputs.build-root-directory }}
|
build-root-directory: ${{ inputs.build-root-directory }}
|
||||||
cache-encryption-key: ${{ inputs.cache-encryption-key }}
|
cache-encryption-key: ${{ inputs.cache-encryption-key }}
|
||||||
build-scan-publish: ${{ inputs.build-scan-publish }}
|
build-scan-publish: ${{ inputs.build-scan-publish }}
|
||||||
build-scan-terms-of-service-url: ${{ inputs.build-scan-terms-of-service-url }}
|
build-scan-terms-of-use-url: ${{ inputs.build-scan-terms-of-use-url }}
|
||||||
build-scan-terms-of-service-agree: ${{ inputs.build-scan-terms-of-service-agree }}
|
build-scan-terms-of-use-agree: ${{ inputs.build-scan-terms-of-use-agree }}
|
||||||
artifact-retention-days: 1
|
artifact-retention-days: 1
|
||||||
arguments: |
|
arguments: |
|
||||||
-Dorg.gradle.configureondemand=false
|
-Dorg.gradle.configureondemand=false
|
||||||
|
38
dist/setup-gradle/main/index.js
vendored
38
dist/setup-gradle/main/index.js
vendored
@ -139453,19 +139453,22 @@ exports.setup = void 0;
|
|||||||
const core = __importStar(__nccwpck_require__(42186));
|
const core = __importStar(__nccwpck_require__(42186));
|
||||||
const input_params_1 = __nccwpck_require__(23885);
|
const input_params_1 = __nccwpck_require__(23885);
|
||||||
function setup() {
|
function setup() {
|
||||||
if ((0, input_params_1.getBuildScanPublishEnabled)() && verifyTermsOfServiceAgreement()) {
|
maybeExportVariable('DEVELOCITY_INJECTION_INIT_SCRIPT_NAME', 'gradle-actions.inject-develocity.init.gradle');
|
||||||
|
maybeExportVariable('DEVELOCITY_AUTO_INJECTION_CUSTOM_VALUE', 'gradle-actions');
|
||||||
|
if ((0, input_params_1.getBuildScanPublishEnabled)() && verifyTermsOfUseAgreement()) {
|
||||||
maybeExportVariable('DEVELOCITY_INJECTION_ENABLED', 'true');
|
maybeExportVariable('DEVELOCITY_INJECTION_ENABLED', 'true');
|
||||||
maybeExportVariable('DEVELOCITY_PLUGIN_VERSION', '3.16.2');
|
maybeExportVariable('DEVELOCITY_PLUGIN_VERSION', '3.16.2');
|
||||||
maybeExportVariable('DEVELOCITY_CCUD_PLUGIN_VERSION', '1.13');
|
maybeExportVariable('DEVELOCITY_CCUD_PLUGIN_VERSION', '1.13');
|
||||||
maybeExportVariable('BUILD_SCAN_TERMS_OF_SERVICE_URL', (0, input_params_1.getBuildScanTermsOfServiceUrl)());
|
maybeExportVariable('DEVELOCITY_TERMS_OF_USE_URL', (0, input_params_1.getBuildScanTermsOfUseUrl)());
|
||||||
maybeExportVariable('BUILD_SCAN_TERMS_OF_SERVICE_AGREE', (0, input_params_1.getBuildScanTermsOfServiceAgree)());
|
maybeExportVariable('DEVELOCITY_TERMS_OF_USE_AGREE', (0, input_params_1.getBuildScanTermsOfUseAgree)());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.setup = setup;
|
exports.setup = setup;
|
||||||
function verifyTermsOfServiceAgreement() {
|
function verifyTermsOfUseAgreement() {
|
||||||
if ((0, input_params_1.getBuildScanTermsOfServiceUrl)() !== 'https://gradle.com/terms-of-service' ||
|
if (((0, input_params_1.getBuildScanTermsOfUseUrl)() !== 'https://gradle.com/terms-of-service' &&
|
||||||
(0, input_params_1.getBuildScanTermsOfServiceAgree)() !== 'yes') {
|
(0, input_params_1.getBuildScanTermsOfUseUrl)() !== 'https://gradle.com/help/legal-terms-of-use') ||
|
||||||
core.warning(`Terms of service must be agreed in order to publish build scans.`);
|
(0, input_params_1.getBuildScanTermsOfUseAgree)() !== 'yes') {
|
||||||
|
core.warning(`Terms of use must be agreed in order to publish build scans.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -141322,7 +141325,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.JobSummaryOption = exports.DependencyGraphOption = exports.parseNumericInput = exports.getArtifactRetentionDays = exports.getDependencyGraphContinueOnFailure = exports.getDependencyGraphOption = exports.getBuildScanTermsOfServiceAgree = exports.getBuildScanTermsOfServiceUrl = exports.getBuildScanPublishEnabled = exports.getPRCommentOption = exports.getJobSummaryOption = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.getCacheEncryptionKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
|
exports.JobSummaryOption = exports.DependencyGraphOption = exports.parseNumericInput = exports.getArtifactRetentionDays = exports.getDependencyGraphContinueOnFailure = exports.getDependencyGraphOption = exports.getBuildScanTermsOfUseAgree = exports.getBuildScanTermsOfUseUrl = exports.getBuildScanPublishEnabled = exports.getPRCommentOption = exports.getJobSummaryOption = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.getCacheEncryptionKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(42186));
|
const core = __importStar(__nccwpck_require__(42186));
|
||||||
const string_argv_1 = __nccwpck_require__(19663);
|
const string_argv_1 = __nccwpck_require__(19663);
|
||||||
function isCacheDisabled() {
|
function isCacheDisabled() {
|
||||||
@ -141402,14 +141405,21 @@ function getBuildScanPublishEnabled() {
|
|||||||
return getBooleanInput('build-scan-publish');
|
return getBooleanInput('build-scan-publish');
|
||||||
}
|
}
|
||||||
exports.getBuildScanPublishEnabled = getBuildScanPublishEnabled;
|
exports.getBuildScanPublishEnabled = getBuildScanPublishEnabled;
|
||||||
function getBuildScanTermsOfServiceUrl() {
|
function getBuildScanTermsOfUseUrl() {
|
||||||
return core.getInput('build-scan-terms-of-service-url');
|
return getTermsOfUseProp('build-scan-terms-of-use-url', 'build-scan-terms-of-service-url');
|
||||||
}
|
}
|
||||||
exports.getBuildScanTermsOfServiceUrl = getBuildScanTermsOfServiceUrl;
|
exports.getBuildScanTermsOfUseUrl = getBuildScanTermsOfUseUrl;
|
||||||
function getBuildScanTermsOfServiceAgree() {
|
function getBuildScanTermsOfUseAgree() {
|
||||||
return core.getInput('build-scan-terms-of-service-agree');
|
return getTermsOfUseProp('build-scan-terms-of-use-agree', 'build-scan-terms-of-service-agree');
|
||||||
|
}
|
||||||
|
exports.getBuildScanTermsOfUseAgree = getBuildScanTermsOfUseAgree;
|
||||||
|
function getTermsOfUseProp(newPropName, oldPropName) {
|
||||||
|
const newProp = core.getInput(newPropName);
|
||||||
|
if (newProp !== '') {
|
||||||
|
return newProp;
|
||||||
|
}
|
||||||
|
return core.getInput(oldPropName);
|
||||||
}
|
}
|
||||||
exports.getBuildScanTermsOfServiceAgree = getBuildScanTermsOfServiceAgree;
|
|
||||||
function parseJobSummaryOption(paramName) {
|
function parseJobSummaryOption(paramName) {
|
||||||
const val = core.getInput(paramName);
|
const val = core.getInput(paramName);
|
||||||
switch (val.toLowerCase().trim()) {
|
switch (val.toLowerCase().trim()) {
|
||||||
|
2
dist/setup-gradle/main/index.js.map
vendored
2
dist/setup-gradle/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
38
dist/setup-gradle/post/index.js
vendored
38
dist/setup-gradle/post/index.js
vendored
@ -136906,19 +136906,22 @@ exports.setup = void 0;
|
|||||||
const core = __importStar(__nccwpck_require__(42186));
|
const core = __importStar(__nccwpck_require__(42186));
|
||||||
const input_params_1 = __nccwpck_require__(23885);
|
const input_params_1 = __nccwpck_require__(23885);
|
||||||
function setup() {
|
function setup() {
|
||||||
if ((0, input_params_1.getBuildScanPublishEnabled)() && verifyTermsOfServiceAgreement()) {
|
maybeExportVariable('DEVELOCITY_INJECTION_INIT_SCRIPT_NAME', 'gradle-actions.inject-develocity.init.gradle');
|
||||||
|
maybeExportVariable('DEVELOCITY_AUTO_INJECTION_CUSTOM_VALUE', 'gradle-actions');
|
||||||
|
if ((0, input_params_1.getBuildScanPublishEnabled)() && verifyTermsOfUseAgreement()) {
|
||||||
maybeExportVariable('DEVELOCITY_INJECTION_ENABLED', 'true');
|
maybeExportVariable('DEVELOCITY_INJECTION_ENABLED', 'true');
|
||||||
maybeExportVariable('DEVELOCITY_PLUGIN_VERSION', '3.16.2');
|
maybeExportVariable('DEVELOCITY_PLUGIN_VERSION', '3.16.2');
|
||||||
maybeExportVariable('DEVELOCITY_CCUD_PLUGIN_VERSION', '1.13');
|
maybeExportVariable('DEVELOCITY_CCUD_PLUGIN_VERSION', '1.13');
|
||||||
maybeExportVariable('BUILD_SCAN_TERMS_OF_SERVICE_URL', (0, input_params_1.getBuildScanTermsOfServiceUrl)());
|
maybeExportVariable('DEVELOCITY_TERMS_OF_USE_URL', (0, input_params_1.getBuildScanTermsOfUseUrl)());
|
||||||
maybeExportVariable('BUILD_SCAN_TERMS_OF_SERVICE_AGREE', (0, input_params_1.getBuildScanTermsOfServiceAgree)());
|
maybeExportVariable('DEVELOCITY_TERMS_OF_USE_AGREE', (0, input_params_1.getBuildScanTermsOfUseAgree)());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.setup = setup;
|
exports.setup = setup;
|
||||||
function verifyTermsOfServiceAgreement() {
|
function verifyTermsOfUseAgreement() {
|
||||||
if ((0, input_params_1.getBuildScanTermsOfServiceUrl)() !== 'https://gradle.com/terms-of-service' ||
|
if (((0, input_params_1.getBuildScanTermsOfUseUrl)() !== 'https://gradle.com/terms-of-service' &&
|
||||||
(0, input_params_1.getBuildScanTermsOfServiceAgree)() !== 'yes') {
|
(0, input_params_1.getBuildScanTermsOfUseUrl)() !== 'https://gradle.com/help/legal-terms-of-use') ||
|
||||||
core.warning(`Terms of service must be agreed in order to publish build scans.`);
|
(0, input_params_1.getBuildScanTermsOfUseAgree)() !== 'yes') {
|
||||||
|
core.warning(`Terms of use must be agreed in order to publish build scans.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -138641,7 +138644,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.JobSummaryOption = exports.DependencyGraphOption = exports.parseNumericInput = exports.getArtifactRetentionDays = exports.getDependencyGraphContinueOnFailure = exports.getDependencyGraphOption = exports.getBuildScanTermsOfServiceAgree = exports.getBuildScanTermsOfServiceUrl = exports.getBuildScanPublishEnabled = exports.getPRCommentOption = exports.getJobSummaryOption = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.getCacheEncryptionKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
|
exports.JobSummaryOption = exports.DependencyGraphOption = exports.parseNumericInput = exports.getArtifactRetentionDays = exports.getDependencyGraphContinueOnFailure = exports.getDependencyGraphOption = exports.getBuildScanTermsOfUseAgree = exports.getBuildScanTermsOfUseUrl = exports.getBuildScanPublishEnabled = exports.getPRCommentOption = exports.getJobSummaryOption = exports.isJobSummaryEnabled = exports.getGithubToken = exports.getJobMatrix = exports.getArguments = exports.getGradleVersion = exports.getBuildRootDirectory = exports.getCacheExcludes = exports.getCacheIncludes = exports.getCacheEncryptionKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheStrictMatch = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(42186));
|
const core = __importStar(__nccwpck_require__(42186));
|
||||||
const string_argv_1 = __nccwpck_require__(19663);
|
const string_argv_1 = __nccwpck_require__(19663);
|
||||||
function isCacheDisabled() {
|
function isCacheDisabled() {
|
||||||
@ -138721,14 +138724,21 @@ function getBuildScanPublishEnabled() {
|
|||||||
return getBooleanInput('build-scan-publish');
|
return getBooleanInput('build-scan-publish');
|
||||||
}
|
}
|
||||||
exports.getBuildScanPublishEnabled = getBuildScanPublishEnabled;
|
exports.getBuildScanPublishEnabled = getBuildScanPublishEnabled;
|
||||||
function getBuildScanTermsOfServiceUrl() {
|
function getBuildScanTermsOfUseUrl() {
|
||||||
return core.getInput('build-scan-terms-of-service-url');
|
return getTermsOfUseProp('build-scan-terms-of-use-url', 'build-scan-terms-of-service-url');
|
||||||
}
|
}
|
||||||
exports.getBuildScanTermsOfServiceUrl = getBuildScanTermsOfServiceUrl;
|
exports.getBuildScanTermsOfUseUrl = getBuildScanTermsOfUseUrl;
|
||||||
function getBuildScanTermsOfServiceAgree() {
|
function getBuildScanTermsOfUseAgree() {
|
||||||
return core.getInput('build-scan-terms-of-service-agree');
|
return getTermsOfUseProp('build-scan-terms-of-use-agree', 'build-scan-terms-of-service-agree');
|
||||||
|
}
|
||||||
|
exports.getBuildScanTermsOfUseAgree = getBuildScanTermsOfUseAgree;
|
||||||
|
function getTermsOfUseProp(newPropName, oldPropName) {
|
||||||
|
const newProp = core.getInput(newPropName);
|
||||||
|
if (newProp !== '') {
|
||||||
|
return newProp;
|
||||||
|
}
|
||||||
|
return core.getInput(oldPropName);
|
||||||
}
|
}
|
||||||
exports.getBuildScanTermsOfServiceAgree = getBuildScanTermsOfServiceAgree;
|
|
||||||
function parseJobSummaryOption(paramName) {
|
function parseJobSummaryOption(paramName) {
|
||||||
const val = core.getInput(paramName);
|
const val = core.getInput(paramName);
|
||||||
switch (val.toLowerCase().trim()) {
|
switch (val.toLowerCase().trim()) {
|
||||||
|
2
dist/setup-gradle/post/index.js.map
vendored
2
dist/setup-gradle/post/index.js.map
vendored
File diff suppressed because one or more lines are too long
@ -688,7 +688,7 @@ The `init-script` supports several additional configuration parameters that you
|
|||||||
Develocity injection is designed to enable the publishing of build scans to a Develocity instance,
|
Develocity injection is designed to enable the publishing of build scans to a Develocity instance,
|
||||||
but is also useful for publishing to the public Build Scans instance (https://scans.gradle.com).
|
but is also useful for publishing to the public Build Scans instance (https://scans.gradle.com).
|
||||||
|
|
||||||
To publish to https://scans.gradle.com, you must specify in your workflow that you accept the [Gradle Terms of Service](https://gradle.com/terms-of-service).
|
To publish to https://scans.gradle.com, you must specify in your workflow that you accept the [Gradle Terms of Use](https://gradle.com/help/legal-terms-of-use).
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: Run build and publish Build Scan
|
name: Run build and publish Build Scan
|
||||||
@ -702,8 +702,8 @@ jobs:
|
|||||||
uses: gradle/actions/setup-gradle@v3
|
uses: gradle/actions/setup-gradle@v3
|
||||||
with:
|
with:
|
||||||
build-scan-publish: true
|
build-scan-publish: true
|
||||||
build-scan-terms-of-service-url: "https://gradle.com/terms-of-service"
|
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
|
||||||
build-scan-terms-of-service-agree: "yes"
|
build-scan-terms-of-use-agree: "yes"
|
||||||
|
|
||||||
- name: Run a Gradle build - a build scan will be published automatically
|
- name: Run a Gradle build - a build scan will be published automatically
|
||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
|
@ -85,19 +85,29 @@ inputs:
|
|||||||
build-scan-publish:
|
build-scan-publish:
|
||||||
description: |
|
description: |
|
||||||
Set to 'true' to automatically publish build results as a Build Scan on scans.gradle.com.
|
Set to 'true' to automatically publish build results as a Build Scan on scans.gradle.com.
|
||||||
For publication to succeed without user input, you must also provide values for `build-scan-terms-of-service-url` and 'build-scan-terms-of-service-agree'.
|
For publication to succeed without user input, you must also provide values for `build-scan-terms-of-use-url` and 'build-scan-terms-of-use-agree'.
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
|
|
||||||
build-scan-terms-of-service-url:
|
build-scan-terms-of-use-url:
|
||||||
description: The URL to the Build Scan® terms of service. This input must be set to 'https://gradle.com/terms-of-service'.
|
description: The URL to the Build Scan® terms of use. This input must be set to 'https://gradle.com/terms-of-service' or 'https://gradle.com/help/legal-terms-of-use'.
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
build-scan-terms-of-service-agree:
|
build-scan-terms-of-use-agree:
|
||||||
description: Indicate that you agree to the Build Scan® terms of service. This input value must be "yes".
|
description: Indicate that you agree to the Build Scan® terms of use. This input value must be "yes".
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
# DEPRECATED ACTION INPUTS
|
# DEPRECATED ACTION INPUTS
|
||||||
|
build-scan-terms-of-service-url:
|
||||||
|
description: The URL to the Build Scan® terms of use. This input must be set to 'https://gradle.com/terms-of-service'.
|
||||||
|
required: false
|
||||||
|
deprecation-message: The input has been renamed to align with the Develocity API. Use 'build-scan-terms-of-use-url' instead.
|
||||||
|
|
||||||
|
build-scan-terms-of-service-agree:
|
||||||
|
description: Indicate that you agree to the Build Scan® terms of use. This input value must be "yes".
|
||||||
|
required: false
|
||||||
|
deprecation-message: The input has been renamed to align with the Develocity API. Use 'build-scan-terms-of-use-agree' instead.
|
||||||
|
|
||||||
arguments:
|
arguments:
|
||||||
description: Gradle command line arguments (supports multi-line input)
|
description: Gradle command line arguments (supports multi-line input)
|
||||||
required: false
|
required: false
|
||||||
|
@ -1,26 +1,25 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {
|
import {getBuildScanPublishEnabled, getBuildScanTermsOfUseUrl, getBuildScanTermsOfUseAgree} from './input-params'
|
||||||
getBuildScanPublishEnabled,
|
|
||||||
getBuildScanTermsOfServiceUrl,
|
|
||||||
getBuildScanTermsOfServiceAgree
|
|
||||||
} from './input-params'
|
|
||||||
|
|
||||||
export function setup(): void {
|
export function setup(): void {
|
||||||
if (getBuildScanPublishEnabled() && verifyTermsOfServiceAgreement()) {
|
maybeExportVariable('DEVELOCITY_INJECTION_INIT_SCRIPT_NAME', 'gradle-actions.inject-develocity.init.gradle')
|
||||||
|
maybeExportVariable('DEVELOCITY_AUTO_INJECTION_CUSTOM_VALUE', 'gradle-actions')
|
||||||
|
if (getBuildScanPublishEnabled() && verifyTermsOfUseAgreement()) {
|
||||||
maybeExportVariable('DEVELOCITY_INJECTION_ENABLED', 'true')
|
maybeExportVariable('DEVELOCITY_INJECTION_ENABLED', 'true')
|
||||||
maybeExportVariable('DEVELOCITY_PLUGIN_VERSION', '3.16.2')
|
maybeExportVariable('DEVELOCITY_PLUGIN_VERSION', '3.16.2')
|
||||||
maybeExportVariable('DEVELOCITY_CCUD_PLUGIN_VERSION', '1.13')
|
maybeExportVariable('DEVELOCITY_CCUD_PLUGIN_VERSION', '1.13')
|
||||||
maybeExportVariable('BUILD_SCAN_TERMS_OF_SERVICE_URL', getBuildScanTermsOfServiceUrl())
|
maybeExportVariable('DEVELOCITY_TERMS_OF_USE_URL', getBuildScanTermsOfUseUrl())
|
||||||
maybeExportVariable('BUILD_SCAN_TERMS_OF_SERVICE_AGREE', getBuildScanTermsOfServiceAgree())
|
maybeExportVariable('DEVELOCITY_TERMS_OF_USE_AGREE', getBuildScanTermsOfUseAgree())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function verifyTermsOfServiceAgreement(): boolean {
|
function verifyTermsOfUseAgreement(): boolean {
|
||||||
if (
|
if (
|
||||||
getBuildScanTermsOfServiceUrl() !== 'https://gradle.com/terms-of-service' ||
|
(getBuildScanTermsOfUseUrl() !== 'https://gradle.com/terms-of-service' &&
|
||||||
getBuildScanTermsOfServiceAgree() !== 'yes'
|
getBuildScanTermsOfUseUrl() !== 'https://gradle.com/help/legal-terms-of-use') ||
|
||||||
|
getBuildScanTermsOfUseAgree() !== 'yes'
|
||||||
) {
|
) {
|
||||||
core.warning(`Terms of service must be agreed in order to publish build scans.`)
|
core.warning(`Terms of use must be agreed in order to publish build scans.`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -79,12 +79,23 @@ export function getBuildScanPublishEnabled(): boolean {
|
|||||||
return getBooleanInput('build-scan-publish')
|
return getBooleanInput('build-scan-publish')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBuildScanTermsOfServiceUrl(): string {
|
export function getBuildScanTermsOfUseUrl(): string {
|
||||||
return core.getInput('build-scan-terms-of-service-url')
|
return getTermsOfUseProp('build-scan-terms-of-use-url', 'build-scan-terms-of-service-url')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBuildScanTermsOfServiceAgree(): string {
|
export function getBuildScanTermsOfUseAgree(): string {
|
||||||
return core.getInput('build-scan-terms-of-service-agree')
|
return getTermsOfUseProp('build-scan-terms-of-use-agree', 'build-scan-terms-of-service-agree')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO @bigdaz: remove the deprecated input property in the next major release of the action
|
||||||
|
*/
|
||||||
|
function getTermsOfUseProp(newPropName: string, oldPropName: string): string {
|
||||||
|
const newProp = core.getInput(newPropName)
|
||||||
|
if (newProp !== '') {
|
||||||
|
return newProp
|
||||||
|
}
|
||||||
|
return core.getInput(oldPropName)
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseJobSummaryOption(paramName: string): JobSummaryOption {
|
function parseJobSummaryOption(paramName: string): JobSummaryOption {
|
||||||
|
@ -28,6 +28,9 @@ if (isTopLevelBuild) {
|
|||||||
settings.pluginManager.withPlugin("com.gradle.enterprise") {
|
settings.pluginManager.withPlugin("com.gradle.enterprise") {
|
||||||
captureUsingBuildScanPublished(settings.extensions["gradleEnterprise"].buildScan, settings.rootProject, invocationId)
|
captureUsingBuildScanPublished(settings.extensions["gradleEnterprise"].buildScan, settings.rootProject, invocationId)
|
||||||
}
|
}
|
||||||
|
settings.pluginManager.withPlugin("com.gradle.develocity") {
|
||||||
|
captureUsingBuildScanPublished(settings.extensions["develocity"].buildScan, settings.rootProject, invocationId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (atLeastGradle3) {
|
} else if (atLeastGradle3) {
|
||||||
projectsEvaluated { gradle ->
|
projectsEvaluated { gradle ->
|
||||||
@ -104,7 +107,13 @@ class BuildResults {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def setBuildResult(def result) {
|
def setBuildResult(def result) {
|
||||||
buildResults['buildFailed'] = result.failure != null
|
try {
|
||||||
|
// Gradle and old Build Scan/Gradle Enterprise plugins report a single optional failure in the build result
|
||||||
|
buildResults['buildFailed'] = result.failure != null
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Develocity plugin unwraps all build failures and reports them as a mandatory array
|
||||||
|
buildResults['buildFailed'] = !result.failures.empty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def setBuildScanUri(def buildScanUrl) {
|
def setBuildScanUri(def buildScanUrl) {
|
||||||
|
@ -2,7 +2,7 @@ import org.gradle.util.GradleVersion
|
|||||||
|
|
||||||
// note that there is no mechanism to share code between the initscript{} block and the main script, so some logic is duplicated
|
// note that there is no mechanism to share code between the initscript{} block and the main script, so some logic is duplicated
|
||||||
|
|
||||||
// conditionally apply the GE / Build Scan plugin to the classpath so it can be applied to the build further down in this script
|
// conditionally apply the Develocity plugin to the classpath so it can be applied to the build further down in this script
|
||||||
initscript {
|
initscript {
|
||||||
def isTopLevelBuild = !gradle.parent
|
def isTopLevelBuild = !gradle.parent
|
||||||
if (!isTopLevelBuild) {
|
if (!isTopLevelBuild) {
|
||||||
@ -14,6 +14,12 @@ initscript {
|
|||||||
return System.getProperty(name) ?: System.getenv(envVarName)
|
return System.getProperty(name) ?: System.getenv(envVarName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def requestedInitScriptName = getInputParam('develocity.injection.init-script-name')
|
||||||
|
def initScriptName = buildscript.sourceFile.name
|
||||||
|
if (requestedInitScriptName != initScriptName) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// finish early if injection is disabled
|
// finish early if injection is disabled
|
||||||
def gradleInjectionEnabled = getInputParam("develocity.injection-enabled")
|
def gradleInjectionEnabled = getInputParam("develocity.injection-enabled")
|
||||||
if (gradleInjectionEnabled != "true") {
|
if (gradleInjectionEnabled != "true") {
|
||||||
@ -23,13 +29,13 @@ initscript {
|
|||||||
def pluginRepositoryUrl = getInputParam('gradle.plugin-repository.url')
|
def pluginRepositoryUrl = getInputParam('gradle.plugin-repository.url')
|
||||||
def pluginRepositoryUsername = getInputParam('gradle.plugin-repository.username')
|
def pluginRepositoryUsername = getInputParam('gradle.plugin-repository.username')
|
||||||
def pluginRepositoryPassword = getInputParam('gradle.plugin-repository.password')
|
def pluginRepositoryPassword = getInputParam('gradle.plugin-repository.password')
|
||||||
def gePluginVersion = getInputParam('develocity.plugin.version')
|
def develocityPluginVersion = getInputParam('develocity.plugin.version')
|
||||||
def ccudPluginVersion = getInputParam('develocity.ccud-plugin.version')
|
def ccudPluginVersion = getInputParam('develocity.ccud-plugin.version')
|
||||||
|
|
||||||
def atLeastGradle5 = GradleVersion.current() >= GradleVersion.version('5.0')
|
def atLeastGradle5 = GradleVersion.current() >= GradleVersion.version('5.0')
|
||||||
def atLeastGradle4 = GradleVersion.current() >= GradleVersion.version('4.0')
|
def atLeastGradle4 = GradleVersion.current() >= GradleVersion.version('4.0')
|
||||||
|
|
||||||
if (gePluginVersion || ccudPluginVersion && atLeastGradle4) {
|
if (develocityPluginVersion || ccudPluginVersion && atLeastGradle4) {
|
||||||
pluginRepositoryUrl = pluginRepositoryUrl ?: 'https://plugins.gradle.org/m2'
|
pluginRepositoryUrl = pluginRepositoryUrl ?: 'https://plugins.gradle.org/m2'
|
||||||
logger.lifecycle("Develocity plugins resolution: $pluginRepositoryUrl")
|
logger.lifecycle("Develocity plugins resolution: $pluginRepositoryUrl")
|
||||||
|
|
||||||
@ -51,10 +57,16 @@ initscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
if (gePluginVersion) {
|
if (develocityPluginVersion) {
|
||||||
classpath atLeastGradle5 ?
|
if (atLeastGradle5) {
|
||||||
"com.gradle:gradle-enterprise-gradle-plugin:$gePluginVersion" :
|
if (GradleVersion.version(develocityPluginVersion) >= GradleVersion.version("3.17")) {
|
||||||
"com.gradle:build-scan-plugin:1.16"
|
classpath "com.gradle:develocity-gradle-plugin:$develocityPluginVersion"
|
||||||
|
} else {
|
||||||
|
classpath "com.gradle:gradle-enterprise-gradle-plugin:$develocityPluginVersion"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
classpath "com.gradle:build-scan-plugin:1.16"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ccudPluginVersion && atLeastGradle4) {
|
if (ccudPluginVersion && atLeastGradle4) {
|
||||||
@ -66,11 +78,17 @@ initscript {
|
|||||||
def BUILD_SCAN_PLUGIN_ID = 'com.gradle.build-scan'
|
def BUILD_SCAN_PLUGIN_ID = 'com.gradle.build-scan'
|
||||||
def BUILD_SCAN_PLUGIN_CLASS = 'com.gradle.scan.plugin.BuildScanPlugin'
|
def BUILD_SCAN_PLUGIN_CLASS = 'com.gradle.scan.plugin.BuildScanPlugin'
|
||||||
|
|
||||||
def DEVELOCITY_PLUGIN_ID = 'com.gradle.enterprise'
|
def GRADLE_ENTERPRISE_PLUGIN_ID = 'com.gradle.enterprise'
|
||||||
def DEVELOCITY_PLUGIN_CLASS = 'com.gradle.enterprise.gradleplugin.GradleEnterprisePlugin'
|
def GRADLE_ENTERPRISE_PLUGIN_CLASS = 'com.gradle.enterprise.gradleplugin.GradleEnterprisePlugin'
|
||||||
def DEVELOCITY_EXTENSION_CLASS = 'com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension'
|
def GRADLE_ENTERPRISE_EXTENSION_CLASS = 'com.gradle.enterprise.gradleplugin.GradleEnterpriseExtension'
|
||||||
|
|
||||||
|
def DEVELOCITY_PLUGIN_ID = 'com.gradle.develocity'
|
||||||
|
def DEVELOCITY_PLUGIN_CLASS = 'com.gradle.develocity.agent.gradle.DevelocityPlugin'
|
||||||
|
def DEVELOCITY_CONFIGURATION_CLASS = 'com.gradle.develocity.agent.gradle.DevelocityConfiguration'
|
||||||
|
|
||||||
|
def SETTINGS_EXTENSION_CLASSES = [GRADLE_ENTERPRISE_EXTENSION_CLASS, DEVELOCITY_CONFIGURATION_CLASS]
|
||||||
|
|
||||||
def CI_AUTO_INJECTION_CUSTOM_VALUE_NAME = 'CI auto injection'
|
def CI_AUTO_INJECTION_CUSTOM_VALUE_NAME = 'CI auto injection'
|
||||||
def CI_AUTO_INJECTION_CUSTOM_VALUE_VALUE = 'gradle-actions'
|
|
||||||
def CCUD_PLUGIN_ID = 'com.gradle.common-custom-user-data-gradle-plugin'
|
def CCUD_PLUGIN_ID = 'com.gradle.common-custom-user-data-gradle-plugin'
|
||||||
def CCUD_PLUGIN_CLASS = 'com.gradle.CommonCustomUserDataGradlePlugin'
|
def CCUD_PLUGIN_CLASS = 'com.gradle.CommonCustomUserDataGradlePlugin'
|
||||||
|
|
||||||
@ -84,24 +102,40 @@ def getInputParam = { String name ->
|
|||||||
return System.getProperty(name) ?: System.getenv(envVarName)
|
return System.getProperty(name) ?: System.getenv(envVarName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def requestedInitScriptName = getInputParam('develocity.injection.init-script-name')
|
||||||
|
def initScriptName = buildscript.sourceFile.name
|
||||||
|
if (requestedInitScriptName != initScriptName) {
|
||||||
|
logger.quiet("Ignoring init script '${initScriptName}' as requested name '${requestedInitScriptName}' does not match")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// finish early if injection is disabled
|
// finish early if injection is disabled
|
||||||
def gradleInjectionEnabled = getInputParam("develocity.injection-enabled")
|
def gradleInjectionEnabled = getInputParam("develocity.injection-enabled")
|
||||||
if (gradleInjectionEnabled != "true") {
|
if (gradleInjectionEnabled != "true") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
def geUrl = getInputParam('develocity.url')
|
def develocityUrl = getInputParam('develocity.url')
|
||||||
def geAllowUntrustedServer = Boolean.parseBoolean(getInputParam('develocity.allow-untrusted-server'))
|
def develocityAllowUntrustedServer = Boolean.parseBoolean(getInputParam('develocity.allow-untrusted-server'))
|
||||||
def geEnforceUrl = Boolean.parseBoolean(getInputParam('develocity.enforce-url'))
|
def develocityEnforceUrl = Boolean.parseBoolean(getInputParam('develocity.enforce-url'))
|
||||||
def buildScanUploadInBackground = Boolean.parseBoolean(getInputParam('develocity.build-scan.upload-in-background'))
|
def buildScanUploadInBackground = Boolean.parseBoolean(getInputParam('develocity.build-scan.upload-in-background'))
|
||||||
def develocityCaptureFileFingerprints = getInputParam('develocity.capture-file-fingerprints') ? Boolean.parseBoolean(getInputParam('develocity.capture-file-fingerprints')) : true
|
def develocityCaptureFileFingerprints = getInputParam('develocity.capture-file-fingerprints') ? Boolean.parseBoolean(getInputParam('develocity.capture-file-fingerprints')) : true
|
||||||
def gePluginVersion = getInputParam('develocity.plugin.version')
|
def develocityPluginVersion = getInputParam('develocity.plugin.version')
|
||||||
def ccudPluginVersion = getInputParam('develocity.ccud-plugin.version')
|
def ccudPluginVersion = getInputParam('develocity.ccud-plugin.version')
|
||||||
def buildScanTermsOfServiceUrl = getInputParam('build-scan.terms-of-service.url')
|
def buildScanTermsOfUseUrl = getInputParam('develocity.terms-of-use.url')
|
||||||
def buildScanTermsOfServiceAgree = getInputParam('build-scan.terms-of-service.agree')
|
def buildScanTermsOfUseAgree = getInputParam('develocity.terms-of-use.agree')
|
||||||
|
def ciAutoInjectionCustomValueValue = getInputParam('develocity.auto-injection.custom-value')
|
||||||
|
|
||||||
def atLeastGradle5 = GradleVersion.current() >= GradleVersion.version('5.0')
|
def atLeastGradle5 = GradleVersion.current() >= GradleVersion.version('5.0')
|
||||||
def atLeastGradle4 = GradleVersion.current() >= GradleVersion.version('4.0')
|
def atLeastGradle4 = GradleVersion.current() >= GradleVersion.version('4.0')
|
||||||
|
def shouldApplyDevelocityPlugin = atLeastGradle5 && develocityPluginVersion && isAtLeast(develocityPluginVersion, '3.17')
|
||||||
|
|
||||||
|
def dvOrGe = { def dvValue, def geValue ->
|
||||||
|
if (shouldApplyDevelocityPlugin) {
|
||||||
|
return dvValue instanceof Closure<?> ? dvValue() : dvValue
|
||||||
|
}
|
||||||
|
return geValue instanceof Closure<?> ? geValue() : geValue
|
||||||
|
}
|
||||||
|
|
||||||
// finish early if configuration parameters passed in via system properties are not valid/supported
|
// finish early if configuration parameters passed in via system properties are not valid/supported
|
||||||
if (ccudPluginVersion && isNotAtLeast(ccudPluginVersion, '1.7')) {
|
if (ccudPluginVersion && isNotAtLeast(ccudPluginVersion, '1.7')) {
|
||||||
@ -109,50 +143,82 @@ if (ccudPluginVersion && isNotAtLeast(ccudPluginVersion, '1.7')) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// register buildScanPublished listener and optionally apply the GE / Build Scan plugin
|
// register buildScanPublished listener and optionally apply the Develocity plugin
|
||||||
if (GradleVersion.current() < GradleVersion.version('6.0')) {
|
if (GradleVersion.current() < GradleVersion.version('6.0')) {
|
||||||
rootProject {
|
rootProject {
|
||||||
buildscript.configurations.getByName("classpath").incoming.afterResolve { ResolvableDependencies incoming ->
|
buildscript.configurations.getByName("classpath").incoming.afterResolve { ResolvableDependencies incoming ->
|
||||||
def resolutionResult = incoming.resolutionResult
|
def resolutionResult = incoming.resolutionResult
|
||||||
|
|
||||||
if (gePluginVersion) {
|
if (develocityPluginVersion) {
|
||||||
def scanPluginComponent = resolutionResult.allComponents.find {
|
def scanPluginComponent = resolutionResult.allComponents.find {
|
||||||
it.moduleVersion.with { group == "com.gradle" && (name == "build-scan-plugin" || name == "gradle-enterprise-gradle-plugin") }
|
it.moduleVersion.with { group == "com.gradle" && ['build-scan-plugin', 'gradle-enterprise-gradle-plugin', 'develocity-gradle-plugin'].contains(name) }
|
||||||
}
|
}
|
||||||
if (!scanPluginComponent) {
|
if (!scanPluginComponent) {
|
||||||
logger.lifecycle("Applying $BUILD_SCAN_PLUGIN_CLASS via init script")
|
def pluginClass = dvOrGe(DEVELOCITY_PLUGIN_CLASS, BUILD_SCAN_PLUGIN_CLASS)
|
||||||
applyPluginExternally(pluginManager, BUILD_SCAN_PLUGIN_CLASS)
|
logger.lifecycle("Applying $pluginClass via init script")
|
||||||
if (geUrl) {
|
applyPluginExternally(pluginManager, pluginClass)
|
||||||
logger.lifecycle("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
|
def rootExtension = dvOrGe(
|
||||||
buildScan.server = geUrl
|
{ develocity },
|
||||||
buildScan.allowUntrustedServer = geAllowUntrustedServer
|
{ buildScan }
|
||||||
|
)
|
||||||
|
def buildScanExtension = dvOrGe(
|
||||||
|
{ rootExtension.buildScan },
|
||||||
|
{ rootExtension }
|
||||||
|
)
|
||||||
|
if (develocityUrl) {
|
||||||
|
logger.lifecycle("Connection to Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer, captureFileFingerprints: $develocityCaptureFileFingerprints")
|
||||||
|
rootExtension.server = develocityUrl
|
||||||
|
rootExtension.allowUntrustedServer = develocityAllowUntrustedServer
|
||||||
}
|
}
|
||||||
buildScan.publishAlways()
|
if (!shouldApplyDevelocityPlugin) {
|
||||||
if (buildScan.metaClass.respondsTo(buildScan, 'setUploadInBackground', Boolean)) buildScan.uploadInBackground = buildScanUploadInBackground // uploadInBackground not available for build-scan-plugin 1.16
|
// Develocity plugin publishes scans by default
|
||||||
buildScan.value CI_AUTO_INJECTION_CUSTOM_VALUE_NAME, CI_AUTO_INJECTION_CUSTOM_VALUE_VALUE
|
buildScanExtension.publishAlways()
|
||||||
if (isAtLeast(gePluginVersion, '2.1') && atLeastGradle5) {
|
}
|
||||||
|
// uploadInBackground not available for build-scan-plugin 1.16
|
||||||
|
if (buildScanExtension.metaClass.respondsTo(buildScanExtension, 'setUploadInBackground', Boolean)) buildScanExtension.uploadInBackground = buildScanUploadInBackground
|
||||||
|
buildScanExtension.value CI_AUTO_INJECTION_CUSTOM_VALUE_NAME, ciAutoInjectionCustomValueValue
|
||||||
|
if (isAtLeast(develocityPluginVersion, '2.1') && atLeastGradle5) {
|
||||||
logger.lifecycle("Setting captureFileFingerprints: $develocityCaptureFileFingerprints")
|
logger.lifecycle("Setting captureFileFingerprints: $develocityCaptureFileFingerprints")
|
||||||
if (isAtLeast(gePluginVersion, '3.7')) {
|
if (isAtLeast(develocityPluginVersion, '3.17')) {
|
||||||
buildScan.capture.taskInputFiles = develocityCaptureFileFingerprints
|
buildScanExtension.capture.fileFingerprints.set(develocityCaptureFileFingerprints)
|
||||||
|
} else if (isAtLeast(develocityPluginVersion, '3.7')) {
|
||||||
|
buildScanExtension.capture.taskInputFiles = develocityCaptureFileFingerprints
|
||||||
} else {
|
} else {
|
||||||
buildScan.captureTaskInputFiles = develocityCaptureFileFingerprints
|
buildScanExtension.captureTaskInputFiles = develocityCaptureFileFingerprints
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (geUrl && geEnforceUrl) {
|
if (develocityUrl && develocityEnforceUrl) {
|
||||||
pluginManager.withPlugin(BUILD_SCAN_PLUGIN_ID) {
|
logger.lifecycle("Enforcing Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer, captureFileFingerprints: $develocityCaptureFileFingerprints")
|
||||||
afterEvaluate {
|
}
|
||||||
logger.lifecycle("Enforcing Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
|
|
||||||
buildScan.server = geUrl
|
pluginManager.withPlugin(BUILD_SCAN_PLUGIN_ID) {
|
||||||
buildScan.allowUntrustedServer = geAllowUntrustedServer
|
afterEvaluate {
|
||||||
|
if (develocityUrl && develocityEnforceUrl) {
|
||||||
|
buildScan.server = develocityUrl
|
||||||
|
buildScan.allowUntrustedServer = develocityAllowUntrustedServer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buildScanTermsOfUseUrl && buildScanTermsOfUseAgree) {
|
||||||
|
buildScan.termsOfServiceUrl = buildScanTermsOfUseUrl
|
||||||
|
buildScan.termsOfServiceAgree = buildScanTermsOfUseAgree
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buildScanTermsOfServiceUrl && buildScanTermsOfServiceAgree) {
|
pluginManager.withPlugin(DEVELOCITY_PLUGIN_ID) {
|
||||||
buildScan.termsOfServiceUrl = buildScanTermsOfServiceUrl
|
afterEvaluate {
|
||||||
buildScan.termsOfServiceAgree = buildScanTermsOfServiceAgree
|
if (develocityUrl && develocityEnforceUrl) {
|
||||||
|
develocity.server = develocityUrl
|
||||||
|
develocity.allowUntrustedServer = develocityAllowUntrustedServer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buildScanTermsOfUseUrl && buildScanTermsOfUseAgree) {
|
||||||
|
develocity.buildScan.termsOfUseUrl = buildScanTermsOfUseUrl
|
||||||
|
develocity.buildScan.termsOfUseAgree = buildScanTermsOfUseAgree
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,42 +235,66 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gradle.settingsEvaluated { settings ->
|
gradle.settingsEvaluated { settings ->
|
||||||
if (gePluginVersion) {
|
if (develocityPluginVersion) {
|
||||||
if (!settings.pluginManager.hasPlugin(DEVELOCITY_PLUGIN_ID)) {
|
if (!settings.pluginManager.hasPlugin(GRADLE_ENTERPRISE_PLUGIN_ID) && !settings.pluginManager.hasPlugin(DEVELOCITY_PLUGIN_ID)) {
|
||||||
logger.lifecycle("Applying $DEVELOCITY_PLUGIN_CLASS via init script")
|
def pluginClass = dvOrGe(DEVELOCITY_PLUGIN_CLASS, GRADLE_ENTERPRISE_PLUGIN_CLASS)
|
||||||
applyPluginExternally(settings.pluginManager, DEVELOCITY_PLUGIN_CLASS)
|
logger.lifecycle("Applying $pluginClass via init script")
|
||||||
eachDevelocityExtension(settings, DEVELOCITY_EXTENSION_CLASS) { ext ->
|
applyPluginExternally(settings.pluginManager, pluginClass)
|
||||||
if (geUrl) {
|
if (develocityUrl) {
|
||||||
logger.lifecycle("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
|
logger.lifecycle("Connection to Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer, captureFileFingerprints: $develocityCaptureFileFingerprints")
|
||||||
ext.server = geUrl
|
eachDevelocitySettingsExtension(settings, SETTINGS_EXTENSION_CLASSES) { ext ->
|
||||||
ext.allowUntrustedServer = geAllowUntrustedServer
|
ext.server = develocityUrl
|
||||||
|
ext.allowUntrustedServer = develocityAllowUntrustedServer
|
||||||
}
|
}
|
||||||
ext.buildScan.publishAlways()
|
}
|
||||||
|
|
||||||
|
eachDevelocitySettingsExtension(settings, SETTINGS_EXTENSION_CLASSES) { ext ->
|
||||||
ext.buildScan.uploadInBackground = buildScanUploadInBackground
|
ext.buildScan.uploadInBackground = buildScanUploadInBackground
|
||||||
if (isAtLeast(gePluginVersion, '2.1')) {
|
ext.buildScan.value CI_AUTO_INJECTION_CUSTOM_VALUE_NAME, ciAutoInjectionCustomValueValue
|
||||||
|
}
|
||||||
|
|
||||||
|
eachDevelocitySettingsExtension(settings, [GRADLE_ENTERPRISE_EXTENSION_CLASS]) { ext ->
|
||||||
|
ext.buildScan.publishAlways()
|
||||||
|
if (isAtLeast(develocityPluginVersion, '2.1')) {
|
||||||
logger.lifecycle("Setting captureFileFingerprints: $develocityCaptureFileFingerprints")
|
logger.lifecycle("Setting captureFileFingerprints: $develocityCaptureFileFingerprints")
|
||||||
if (isAtLeast(gePluginVersion, '3.7')) {
|
if (isAtLeast(develocityPluginVersion, '3.7')) {
|
||||||
ext.buildScan.capture.taskInputFiles = develocityCaptureFileFingerprints
|
ext.buildScan.capture.taskInputFiles = develocityCaptureFileFingerprints
|
||||||
} else {
|
} else {
|
||||||
ext.buildScan.captureTaskInputFiles = develocityCaptureFileFingerprints
|
ext.buildScan.captureTaskInputFiles = develocityCaptureFileFingerprints
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ext.buildScan.value CI_AUTO_INJECTION_CUSTOM_VALUE_NAME, CI_AUTO_INJECTION_CUSTOM_VALUE_VALUE
|
}
|
||||||
|
|
||||||
|
eachDevelocitySettingsExtension(settings, [DEVELOCITY_CONFIGURATION_CLASS]) { ext ->
|
||||||
|
ext.buildScan.capture.fileFingerprints = develocityCaptureFileFingerprints
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (geUrl && geEnforceUrl) {
|
if (develocityUrl && develocityEnforceUrl) {
|
||||||
eachDevelocityExtension(settings, DEVELOCITY_EXTENSION_CLASS) { ext ->
|
logger.lifecycle("Enforcing Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer, captureFileFingerprints: $develocityCaptureFileFingerprints")
|
||||||
logger.lifecycle("Enforcing Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
|
}
|
||||||
ext.server = geUrl
|
|
||||||
ext.allowUntrustedServer = geAllowUntrustedServer
|
eachDevelocitySettingsExtension(settings, [GRADLE_ENTERPRISE_EXTENSION_CLASS]) { ext ->
|
||||||
|
if (develocityUrl && develocityEnforceUrl) {
|
||||||
|
ext.server = develocityUrl
|
||||||
|
ext.allowUntrustedServer = develocityAllowUntrustedServer
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buildScanTermsOfUseUrl && buildScanTermsOfUseAgree) {
|
||||||
|
ext.buildScan.termsOfServiceUrl = buildScanTermsOfUseUrl
|
||||||
|
ext.buildScan.termsOfServiceAgree = buildScanTermsOfUseAgree
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buildScanTermsOfServiceUrl && buildScanTermsOfServiceAgree) {
|
eachDevelocitySettingsExtension(settings, [DEVELOCITY_CONFIGURATION_CLASS]) { ext ->
|
||||||
eachDevelocityExtension(settings, DEVELOCITY_EXTENSION_CLASS) { ext ->
|
if (develocityUrl && develocityEnforceUrl) {
|
||||||
ext.buildScan.termsOfServiceUrl = buildScanTermsOfServiceUrl
|
ext.server = develocityUrl
|
||||||
ext.buildScan.termsOfServiceAgree = buildScanTermsOfServiceAgree
|
ext.allowUntrustedServer = develocityAllowUntrustedServer
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buildScanTermsOfUseUrl && buildScanTermsOfUseAgree) {
|
||||||
|
ext.buildScan.termsOfUseUrl = buildScanTermsOfUseUrl
|
||||||
|
ext.buildScan.termsOfUseAgree = buildScanTermsOfUseAgree
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,8 +310,11 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
|
|||||||
|
|
||||||
void applyPluginExternally(def pluginManager, String pluginClassName) {
|
void applyPluginExternally(def pluginManager, String pluginClassName) {
|
||||||
def externallyApplied = 'develocity.externally-applied'
|
def externallyApplied = 'develocity.externally-applied'
|
||||||
|
def externallyAppliedDeprecated = 'gradle.enterprise.externally-applied'
|
||||||
def oldValue = System.getProperty(externallyApplied)
|
def oldValue = System.getProperty(externallyApplied)
|
||||||
|
def oldValueDeprecated = System.getProperty(externallyAppliedDeprecated)
|
||||||
System.setProperty(externallyApplied, 'true')
|
System.setProperty(externallyApplied, 'true')
|
||||||
|
System.setProperty(externallyAppliedDeprecated, 'true')
|
||||||
try {
|
try {
|
||||||
pluginManager.apply(initscript.classLoader.loadClass(pluginClassName))
|
pluginManager.apply(initscript.classLoader.loadClass(pluginClassName))
|
||||||
} finally {
|
} finally {
|
||||||
@ -230,18 +323,24 @@ void applyPluginExternally(def pluginManager, String pluginClassName) {
|
|||||||
} else {
|
} else {
|
||||||
System.setProperty(externallyApplied, oldValue)
|
System.setProperty(externallyApplied, oldValue)
|
||||||
}
|
}
|
||||||
|
if (oldValueDeprecated == null) {
|
||||||
|
System.clearProperty(externallyAppliedDeprecated)
|
||||||
|
} else {
|
||||||
|
System.setProperty(externallyAppliedDeprecated, oldValueDeprecated)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static def eachDevelocityExtension(def settings, def publicType, def action) {
|
static def eachDevelocitySettingsExtension(def settings, List<String> publicTypes, def action) {
|
||||||
settings.extensions.extensionsSchema.elements.findAll { it.publicType.concreteClass.name == publicType }
|
settings.extensions.extensionsSchema.elements.findAll { publicTypes.contains(it.publicType.concreteClass.name) }
|
||||||
.collect { settings[it.name] }.each(action)
|
.collect { settings[it.name] }
|
||||||
}
|
.each(action)
|
||||||
|
|
||||||
static boolean isNotAtLeast(String versionUnderTest, String referenceVersion) {
|
|
||||||
!isAtLeast(versionUnderTest, referenceVersion)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isAtLeast(String versionUnderTest, String referenceVersion) {
|
static boolean isAtLeast(String versionUnderTest, String referenceVersion) {
|
||||||
GradleVersion.version(versionUnderTest) >= GradleVersion.version(referenceVersion)
|
GradleVersion.version(versionUnderTest) >= GradleVersion.version(referenceVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean isNotAtLeast(String versionUnderTest, String referenceVersion) {
|
||||||
|
!isAtLeast(versionUnderTest, referenceVersion)
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ import java.nio.file.Files
|
|||||||
import java.util.zip.GZIPOutputStream
|
import java.util.zip.GZIPOutputStream
|
||||||
|
|
||||||
class BaseInitScriptTest extends Specification {
|
class BaseInitScriptTest extends Specification {
|
||||||
static final String DEVELOCITY_PLUGIN_VERSION = '3.16.2'
|
static final String DEVELOCITY_PLUGIN_VERSION = '3.17'
|
||||||
static final String CCUD_PLUGIN_VERSION = '1.13'
|
static final String CCUD_PLUGIN_VERSION = '1.13'
|
||||||
|
|
||||||
static final TestGradleVersion GRADLE_3_X = new TestGradleVersion(GradleVersion.version('3.5.1'), 7, 9)
|
static final TestGradleVersion GRADLE_3_X = new TestGradleVersion(GradleVersion.version('3.5.1'), 7, 9)
|
||||||
@ -129,33 +129,26 @@ class BaseInitScriptTest extends Specification {
|
|||||||
buildFile << ''
|
buildFile << ''
|
||||||
}
|
}
|
||||||
|
|
||||||
def declareGePluginApplication(GradleVersion gradleVersion, URI serverUrl = mockScansServer.address) {
|
def declareDevelocityPluginApplication(GradleVersion gradleVersion, URI serverUrl = mockScansServer.address) {
|
||||||
settingsFile.text = maybeAddPluginsToSettings(gradleVersion, null, serverUrl) + settingsFile.text
|
settingsFile.text = maybeAddPluginsToSettings(gradleVersion, null, serverUrl) + settingsFile.text
|
||||||
buildFile.text = maybeAddPluginsToRootProject(gradleVersion, null, serverUrl) + buildFile.text
|
buildFile.text = maybeAddPluginsToRootProject(gradleVersion, null, serverUrl) + buildFile.text
|
||||||
}
|
}
|
||||||
|
|
||||||
def declareGePluginAndCcudPluginApplication(GradleVersion gradleVersion, URI serverUrl = mockScansServer.address) {
|
def declareDevelocityPluginAndCcudPluginApplication(GradleVersion gradleVersion, URI serverUrl = mockScansServer.address) {
|
||||||
settingsFile.text = maybeAddPluginsToSettings(gradleVersion, CCUD_PLUGIN_VERSION, serverUrl) + settingsFile.text
|
settingsFile.text = maybeAddPluginsToSettings(gradleVersion, CCUD_PLUGIN_VERSION, serverUrl) + settingsFile.text
|
||||||
buildFile.text = maybeAddPluginsToRootProject(gradleVersion, CCUD_PLUGIN_VERSION, serverUrl) + buildFile.text
|
buildFile.text = maybeAddPluginsToRootProject(gradleVersion, CCUD_PLUGIN_VERSION, serverUrl) + buildFile.text
|
||||||
}
|
}
|
||||||
|
|
||||||
String maybeAddPluginsToSettings(GradleVersion gradleVersion, String ccudPluginVersion, URI serverUri) {
|
String maybeAddPluginsToSettings(GradleVersion gradleVersion, String ccudPluginVersion, URI serverUri) {
|
||||||
if (gradleVersion < GradleVersion.version('5.0')) {
|
if (gradleVersion < GradleVersion.version('6.0')) {
|
||||||
'' // applied in build.gradle
|
|
||||||
} else if (gradleVersion < GradleVersion.version('6.0')) {
|
|
||||||
'' // applied in build.gradle
|
'' // applied in build.gradle
|
||||||
} else {
|
} else {
|
||||||
"""
|
"""
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.gradle.enterprise' version '${DEVELOCITY_PLUGIN_VERSION}'
|
id 'com.gradle.develocity' version '${DEVELOCITY_PLUGIN_VERSION}'
|
||||||
${ccudPluginVersion ? "id 'com.gradle.common-custom-user-data-gradle-plugin' version '$ccudPluginVersion'" : ""}
|
${ccudPluginVersion ? "id 'com.gradle.common-custom-user-data-gradle-plugin' version '$ccudPluginVersion'" : ""}
|
||||||
}
|
}
|
||||||
gradleEnterprise {
|
develocity.server = '$serverUri'
|
||||||
server = '$serverUri'
|
|
||||||
buildScan {
|
|
||||||
publishAlways()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,15 +168,10 @@ class BaseInitScriptTest extends Specification {
|
|||||||
} else if (gradleVersion < GradleVersion.version('6.0')) {
|
} else if (gradleVersion < GradleVersion.version('6.0')) {
|
||||||
"""
|
"""
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.gradle.build-scan' version '${DEVELOCITY_PLUGIN_VERSION}'
|
id 'com.gradle.develocity' version '${DEVELOCITY_PLUGIN_VERSION}'
|
||||||
${ccudPluginVersion ? "id 'com.gradle.common-custom-user-data-gradle-plugin' version '$ccudPluginVersion'" : ""}
|
${ccudPluginVersion ? "id 'com.gradle.common-custom-user-data-gradle-plugin' version '$ccudPluginVersion'" : ""}
|
||||||
}
|
}
|
||||||
gradleEnterprise {
|
develocity.server = '$serverUrl'
|
||||||
server = '$serverUrl'
|
|
||||||
buildScan {
|
|
||||||
publishAlways()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"""
|
"""
|
||||||
} else {
|
} else {
|
||||||
'' // applied in settings.gradle
|
'' // applied in settings.gradle
|
||||||
|
@ -58,7 +58,7 @@ class TestBuildResultRecorder extends BaseInitScriptTest {
|
|||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
when:
|
when:
|
||||||
declareGePluginApplication(testGradleVersion.gradleVersion)
|
declareDevelocityPluginApplication(testGradleVersion.gradleVersion)
|
||||||
run(['help'], initScript, testGradleVersion.gradleVersion)
|
run(['help'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
then:
|
then:
|
||||||
@ -68,11 +68,11 @@ class TestBuildResultRecorder extends BaseInitScriptTest {
|
|||||||
testGradleVersion << ALL_VERSIONS
|
testGradleVersion << ALL_VERSIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
def "produces build results file for #testGradleVersion with ge-plugin and no build scan published"() {
|
def "produces build results file for #testGradleVersion with Develocity plugin and no build scan published"() {
|
||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
when:
|
when:
|
||||||
declareGePluginApplication(testGradleVersion.gradleVersion)
|
declareDevelocityPluginApplication(testGradleVersion.gradleVersion)
|
||||||
run(['help', '--no-scan'], initScript, testGradleVersion.gradleVersion)
|
run(['help', '--no-scan'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
then:
|
then:
|
||||||
@ -86,7 +86,7 @@ class TestBuildResultRecorder extends BaseInitScriptTest {
|
|||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
when:
|
when:
|
||||||
declareGePluginApplication(testGradleVersion.gradleVersion)
|
declareDevelocityPluginApplication(testGradleVersion.gradleVersion)
|
||||||
addFailingTaskToBuild()
|
addFailingTaskToBuild()
|
||||||
runAndFail(['expectFailure'], initScript, testGradleVersion.gradleVersion)
|
runAndFail(['expectFailure'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ class TestBuildResultRecorder extends BaseInitScriptTest {
|
|||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
when:
|
when:
|
||||||
declareGePluginApplication(testGradleVersion.gradleVersion)
|
declareDevelocityPluginApplication(testGradleVersion.gradleVersion)
|
||||||
run(['help', '--configuration-cache'], initScript, testGradleVersion.gradleVersion)
|
run(['help', '--configuration-cache'], initScript, testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
then:
|
then:
|
||||||
@ -122,7 +122,7 @@ class TestBuildResultRecorder extends BaseInitScriptTest {
|
|||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
when:
|
when:
|
||||||
declareGePluginApplication(testGradleVersion.gradleVersion)
|
declareDevelocityPluginApplication(testGradleVersion.gradleVersion)
|
||||||
addFailingTaskToBuild()
|
addFailingTaskToBuild()
|
||||||
failScanUpload = true
|
failScanUpload = true
|
||||||
runAndFail(['expectFailure'], initScript, testGradleVersion.gradleVersion)
|
runAndFail(['expectFailure'], initScript, testGradleVersion.gradleVersion)
|
||||||
@ -165,7 +165,7 @@ class TestBuildResultRecorder extends BaseInitScriptTest {
|
|||||||
testGradleVersion << ALL_VERSIONS
|
testGradleVersion << ALL_VERSIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
def "produces build results file with build scan when GE plugin is applied in settingsEvaluated"() {
|
def "produces build results file with build scan when Develocity plugin is applied in settingsEvaluated"() {
|
||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
when:
|
when:
|
||||||
|
@ -2,6 +2,7 @@ package com.gradle.gradlebuildaction
|
|||||||
|
|
||||||
import org.gradle.testkit.runner.BuildResult
|
import org.gradle.testkit.runner.BuildResult
|
||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
|
import spock.lang.Requires
|
||||||
|
|
||||||
import static org.junit.Assume.assumeTrue
|
import static org.junit.Assume.assumeTrue
|
||||||
|
|
||||||
@ -10,7 +11,7 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
|
|
||||||
def initScript = 'gradle-actions.inject-develocity.init.gradle'
|
def initScript = 'gradle-actions.inject-develocity.init.gradle'
|
||||||
|
|
||||||
private static final GradleVersion GRADLE_6 = GradleVersion.version('6.0')
|
private static final GradleVersion GRADLE_5 = GradleVersion.version('5.0')
|
||||||
|
|
||||||
def "does not apply Develocity plugins when not requested"() {
|
def "does not apply Develocity plugins when not requested"() {
|
||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
@ -30,7 +31,32 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
given:
|
given:
|
||||||
declareGePluginApplication(testGradleVersion.gradleVersion)
|
declareDevelocityPluginApplication(testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
|
when:
|
||||||
|
def result = run(testGradleVersion, testConfig())
|
||||||
|
|
||||||
|
then:
|
||||||
|
outputMissesDevelocityPluginApplicationViaInitScript(result)
|
||||||
|
outputMissesCcudPluginApplicationViaInitScript(result)
|
||||||
|
|
||||||
|
and:
|
||||||
|
outputContainsBuildScanUrl(result)
|
||||||
|
|
||||||
|
where:
|
||||||
|
testGradleVersion << ALL_VERSIONS
|
||||||
|
}
|
||||||
|
|
||||||
|
@Requires(
|
||||||
|
value = { data.testGradleVersion.gradleVersion >= GradleVersion.version("5.0") },
|
||||||
|
reason = "Prior to Gradle 5.0, we apply a fixed version of the plugin, which can't introduce this conflict"
|
||||||
|
)
|
||||||
|
def "does not override GE or Build Scan plugins even if Develocity plugin is requested"() {
|
||||||
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
|
given:
|
||||||
|
settingsFile.text = maybeAddGradleEnterprisePlugin(testGradleVersion.gradleVersion, '3.16.2')
|
||||||
|
buildFile.text = maybeAddBuildScanPlugin(testGradleVersion.gradleVersion, '3.16.2')
|
||||||
|
|
||||||
when:
|
when:
|
||||||
def result = run(testGradleVersion, testConfig())
|
def result = run(testGradleVersion, testConfig())
|
||||||
@ -63,6 +89,28 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
testGradleVersion << ALL_VERSIONS
|
testGradleVersion << ALL_VERSIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def "applies deprecated Gradle Enterprise or Build Scan plugins if requested"() {
|
||||||
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
|
given:
|
||||||
|
def appliedPluginClass = testGradleVersion.gradleVersion >= GradleVersion.version("6.0")
|
||||||
|
? "com.gradle.enterprise.gradleplugin.GradleEnterprisePlugin"
|
||||||
|
: "com.gradle.scan.plugin.BuildScanPlugin"
|
||||||
|
|
||||||
|
when:
|
||||||
|
// 3.16.2 is the latest version of deprecated plugins
|
||||||
|
def result = run(testGradleVersion, testConfig('3.16.2'))
|
||||||
|
|
||||||
|
then:
|
||||||
|
1 == result.output.count("Applying $appliedPluginClass via init script")
|
||||||
|
|
||||||
|
and:
|
||||||
|
outputContainsBuildScanUrl(result)
|
||||||
|
|
||||||
|
where:
|
||||||
|
testGradleVersion << ALL_VERSIONS
|
||||||
|
}
|
||||||
|
|
||||||
def "applies Develocity and CCUD plugins via init script when not defined in project"() {
|
def "applies Develocity and CCUD plugins via init script when not defined in project"() {
|
||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
@ -84,7 +132,7 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
given:
|
given:
|
||||||
declareGePluginApplication(testGradleVersion.gradleVersion)
|
declareDevelocityPluginApplication(testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
when:
|
when:
|
||||||
def result = run(testGradleVersion, testConfig().withCCUDPlugin())
|
def result = run(testGradleVersion, testConfig().withCCUDPlugin())
|
||||||
@ -104,7 +152,7 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
given:
|
given:
|
||||||
declareGePluginAndCcudPluginApplication(testGradleVersion.gradleVersion)
|
declareDevelocityPluginAndCcudPluginApplication(testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
when:
|
when:
|
||||||
def result = run(testGradleVersion, testConfig().withCCUDPlugin())
|
def result = run(testGradleVersion, testConfig().withCCUDPlugin())
|
||||||
@ -124,7 +172,7 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
given:
|
given:
|
||||||
declareGePluginApplication(testGradleVersion.gradleVersion)
|
declareDevelocityPluginApplication(testGradleVersion.gradleVersion)
|
||||||
|
|
||||||
when:
|
when:
|
||||||
def config = testConfig().withServer(URI.create('https://develocity-server.invalid'))
|
def config = testConfig().withServer(URI.create('https://develocity-server.invalid'))
|
||||||
@ -165,7 +213,7 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
assumeTrue testGradleVersion.compatibleWithCurrentJvm
|
||||||
|
|
||||||
given:
|
given:
|
||||||
declareGePluginApplication(testGradleVersion.gradleVersion, URI.create('https://develocity-server.invalid'))
|
declareDevelocityPluginApplication(testGradleVersion.gradleVersion, URI.create('https://develocity-server.invalid'))
|
||||||
|
|
||||||
when:
|
when:
|
||||||
def config = testConfig().withServer(mockScansServer.address, true)
|
def config = testConfig().withServer(mockScansServer.address, true)
|
||||||
@ -316,24 +364,24 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void outputContainsDevelocityPluginApplicationViaInitScript(BuildResult result, GradleVersion gradleVersion) {
|
void outputContainsDevelocityPluginApplicationViaInitScript(BuildResult result, GradleVersion gradleVersion) {
|
||||||
def pluginApplicationLogMsgGradle4And5 = "Applying com.gradle.scan.plugin.BuildScanPlugin via init script"
|
def pluginApplicationLogMsgGradle4 = "Applying com.gradle.scan.plugin.BuildScanPlugin via init script"
|
||||||
def pluginApplicationLogMsgGradle6AndHigher = "Applying com.gradle.enterprise.gradleplugin.GradleEnterprisePlugin via init script"
|
def pluginApplicationLogMsgGradle5AndHigher = "Applying com.gradle.develocity.agent.gradle.DevelocityPlugin via init script"
|
||||||
if (gradleVersion < GRADLE_6) {
|
if (gradleVersion < GRADLE_5) {
|
||||||
assert result.output.contains(pluginApplicationLogMsgGradle4And5)
|
assert result.output.contains(pluginApplicationLogMsgGradle4)
|
||||||
assert 1 == result.output.count(pluginApplicationLogMsgGradle4And5)
|
assert 1 == result.output.count(pluginApplicationLogMsgGradle4)
|
||||||
assert !result.output.contains(pluginApplicationLogMsgGradle6AndHigher)
|
assert !result.output.contains(pluginApplicationLogMsgGradle5AndHigher)
|
||||||
} else {
|
} else {
|
||||||
assert result.output.contains(pluginApplicationLogMsgGradle6AndHigher)
|
assert result.output.contains(pluginApplicationLogMsgGradle5AndHigher)
|
||||||
assert 1 == result.output.count(pluginApplicationLogMsgGradle6AndHigher)
|
assert 1 == result.output.count(pluginApplicationLogMsgGradle5AndHigher)
|
||||||
assert !result.output.contains(pluginApplicationLogMsgGradle4And5)
|
assert !result.output.contains(pluginApplicationLogMsgGradle4)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void outputMissesDevelocityPluginApplicationViaInitScript(BuildResult result) {
|
void outputMissesDevelocityPluginApplicationViaInitScript(BuildResult result) {
|
||||||
def pluginApplicationLogMsgGradle4And5 = "Applying com.gradle.scan.plugin.BuildScanPlugin via init script"
|
def pluginApplicationLogMsgGradle4 = "Applying com.gradle.scan.plugin.BuildScanPlugin via init script"
|
||||||
def pluginApplicationLogMsgGradle6AndHigher = "Applying com.gradle.enterprise.gradleplugin.GradleEnterprisePlugin via init script"
|
def pluginApplicationLogMsgGradle5AndHigher = "Applying com.gradle.develocity.agent.gradle.DevelocityPlugin via init script"
|
||||||
assert !result.output.contains(pluginApplicationLogMsgGradle4And5)
|
assert !result.output.contains(pluginApplicationLogMsgGradle4)
|
||||||
assert !result.output.contains(pluginApplicationLogMsgGradle6AndHigher)
|
assert !result.output.contains(pluginApplicationLogMsgGradle5AndHigher)
|
||||||
}
|
}
|
||||||
|
|
||||||
void outputContainsCcudPluginApplicationViaInitScript(BuildResult result) {
|
void outputContainsCcudPluginApplicationViaInitScript(BuildResult result) {
|
||||||
@ -347,10 +395,10 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
assert !result.output.contains(pluginApplicationLogMsg)
|
assert !result.output.contains(pluginApplicationLogMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
void outputContainsDevelocityConnectionInfo(BuildResult result, String geUrl, boolean geAllowUntrustedServer) {
|
void outputContainsDevelocityConnectionInfo(BuildResult result, String develocityUrl, boolean develocityAllowUntrustedServer) {
|
||||||
def geConnectionInfo = "Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer"
|
def develocityConnectionInfo = "Connection to Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer"
|
||||||
assert result.output.contains(geConnectionInfo)
|
assert result.output.contains(develocityConnectionInfo)
|
||||||
assert 1 == result.output.count(geConnectionInfo)
|
assert 1 == result.output.count(develocityConnectionInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
void outputCaptureFileFingerprints(BuildResult result, boolean captureFileFingerprints) {
|
void outputCaptureFileFingerprints(BuildResult result, boolean captureFileFingerprints) {
|
||||||
@ -371,8 +419,8 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void outputEnforcesDevelocityUrl(BuildResult result, String geUrl, boolean geAllowUntrustedServer) {
|
void outputEnforcesDevelocityUrl(BuildResult result, String develocityUrl, boolean develocityAllowUntrustedServer) {
|
||||||
def enforceUrl = "Enforcing Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer"
|
def enforceUrl = "Enforcing Develocity: $develocityUrl, allowUntrustedServer: $develocityAllowUntrustedServer"
|
||||||
assert result.output.contains(enforceUrl)
|
assert result.output.contains(enforceUrl)
|
||||||
assert 1 == result.output.count(enforceUrl)
|
assert 1 == result.output.count(enforceUrl)
|
||||||
}
|
}
|
||||||
@ -395,8 +443,52 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestConfig testConfig() {
|
private String maybeAddGradleEnterprisePlugin(GradleVersion gradleVersion, String gePluginVersion) {
|
||||||
new TestConfig()
|
if (gradleVersion < GradleVersion.version('6.0')) {
|
||||||
|
'' // applied in build.gradle
|
||||||
|
} else {
|
||||||
|
"""
|
||||||
|
plugins {
|
||||||
|
id 'com.gradle.enterprise' version '${gePluginVersion}'
|
||||||
|
}
|
||||||
|
gradleEnterprise {
|
||||||
|
server = '${mockScansServer.address}'
|
||||||
|
buildScan {
|
||||||
|
publishAlways()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String maybeAddBuildScanPlugin(GradleVersion gradleVersion, String buildScanPluginVersion) {
|
||||||
|
if (gradleVersion < GradleVersion.version('5.0')) {
|
||||||
|
"""
|
||||||
|
plugins {
|
||||||
|
id 'com.gradle.build-scan' version '1.16'
|
||||||
|
}
|
||||||
|
buildScan {
|
||||||
|
server = '${mockScansServer.address}'
|
||||||
|
publishAlways()
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
} else if (gradleVersion < GradleVersion.version('6.0')) {
|
||||||
|
"""
|
||||||
|
plugins {
|
||||||
|
id 'com.gradle.build-scan' version '${buildScanPluginVersion}'
|
||||||
|
}
|
||||||
|
buildScan {
|
||||||
|
server = '${mockScansServer.address}'
|
||||||
|
publishAlways()
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
} else {
|
||||||
|
'' // applied in settings.gradle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TestConfig testConfig(String develocityPluginVersion = DEVELOCITY_PLUGIN_VERSION) {
|
||||||
|
new TestConfig(develocityPluginVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestConfig {
|
class TestConfig {
|
||||||
@ -407,6 +499,11 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
String pluginRepositoryUsername = null
|
String pluginRepositoryUsername = null
|
||||||
String pluginRepositoryPassword = null
|
String pluginRepositoryPassword = null
|
||||||
boolean captureFileFingerprints = false
|
boolean captureFileFingerprints = false
|
||||||
|
String develocityPluginVersion
|
||||||
|
|
||||||
|
TestConfig(String develocityPluginVersion) {
|
||||||
|
this.develocityPluginVersion = develocityPluginVersion
|
||||||
|
}
|
||||||
|
|
||||||
TestConfig withCCUDPlugin(String version = CCUD_PLUGIN_VERSION) {
|
TestConfig withCCUDPlugin(String version = CCUD_PLUGIN_VERSION) {
|
||||||
ccudPluginVersion = version
|
ccudPluginVersion = version
|
||||||
@ -437,11 +534,13 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
|
|
||||||
def getEnvVars() {
|
def getEnvVars() {
|
||||||
Map<String, String> envVars = [
|
Map<String, String> envVars = [
|
||||||
DEVELOCITY_INJECTION_ENABLED: "true",
|
DEVELOCITY_INJECTION_INIT_SCRIPT_NAME : "gradle-actions.inject-develocity.init.gradle",
|
||||||
DEVELOCITY_URL: serverUrl,
|
DEVELOCITY_INJECTION_ENABLED : "true",
|
||||||
DEVELOCITY_ALLOW_UNTRUSTED_SERVER: "true",
|
DEVELOCITY_URL : serverUrl,
|
||||||
DEVELOCITY_PLUGIN_VERSION: DEVELOCITY_PLUGIN_VERSION,
|
DEVELOCITY_ALLOW_UNTRUSTED_SERVER : "true",
|
||||||
DEVELOCITY_BUILD_SCAN_UPLOAD_IN_BACKGROUND: "true" // Need to upload in background since our Mock server doesn't cope with foreground upload
|
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'
|
||||||
]
|
]
|
||||||
if (enforceUrl) envVars.put("DEVELOCITY_ENFORCE_URL", "true")
|
if (enforceUrl) envVars.put("DEVELOCITY_ENFORCE_URL", "true")
|
||||||
if (ccudPluginVersion != null) envVars.put("DEVELOCITY_CCUD_PLUGIN_VERSION", ccudPluginVersion)
|
if (ccudPluginVersion != null) envVars.put("DEVELOCITY_CCUD_PLUGIN_VERSION", ccudPluginVersion)
|
||||||
@ -455,11 +554,13 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
|
|
||||||
def getJvmArgs() {
|
def getJvmArgs() {
|
||||||
List<String> jvmArgs = [
|
List<String> jvmArgs = [
|
||||||
|
"-Ddevelocity.injection.init-script-name=gradle-actions.inject-develocity.init.gradle",
|
||||||
"-Ddevelocity.injection-enabled=true",
|
"-Ddevelocity.injection-enabled=true",
|
||||||
"-Ddevelocity.url=$serverUrl",
|
"-Ddevelocity.url=$serverUrl",
|
||||||
"-Ddevelocity.allow-untrusted-server=true",
|
"-Ddevelocity.allow-untrusted-server=true",
|
||||||
"-Ddevelocity.plugin.version=$DEVELOCITY_PLUGIN_VERSION",
|
"-Ddevelocity.plugin.version=$develocityPluginVersion",
|
||||||
"-Ddevelocity.build-scan.upload-in-background=true"
|
"-Ddevelocity.build-scan.upload-in-background=true",
|
||||||
|
"-Ddevelocity.auto-injection.custom-value=gradle-actions"
|
||||||
]
|
]
|
||||||
|
|
||||||
if (enforceUrl) jvmArgs.add("-Ddevelocity.enforce-url=true")
|
if (enforceUrl) jvmArgs.add("-Ddevelocity.enforce-url=true")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user