Capture task input files when plugin not applied (#77)

This PR changes the behavior such that task input files are captured
when the environment variable is explicitly specified and for the cases
when the plugin is not applied.

---------

Co-authored-by: Alexis Tual <atual@gradle.com>
This commit is contained in:
Iurii Ignatko
2024-03-25 16:34:45 +02:00
committed by GitHub
parent 393df4bfa2
commit c276584302
2 changed files with 28 additions and 31 deletions

View File

@@ -94,7 +94,7 @@ def geUrl = getInputParam('develocity.url')
def geAllowUntrustedServer = Boolean.parseBoolean(getInputParam('develocity.allow-untrusted-server'))
def geEnforceUrl = Boolean.parseBoolean(getInputParam('develocity.enforce-url'))
def buildScanUploadInBackground = Boolean.parseBoolean(getInputParam('develocity.build-scan.upload-in-background'))
def geCaptureFileFingerprints = Boolean.parseBoolean(getInputParam('develocity.capture-file-fingerprints'))
def develocityCaptureFileFingerprints = getInputParam('develocity.capture-file-fingerprints') ? Boolean.parseBoolean(getInputParam('develocity.capture-file-fingerprints')) : true
def gePluginVersion = getInputParam('develocity.plugin.version')
def ccudPluginVersion = getInputParam('develocity.ccud-plugin.version')
def buildScanTermsOfServiceUrl = getInputParam('build-scan.terms-of-service.url')
@@ -123,36 +123,30 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
logger.lifecycle("Applying $BUILD_SCAN_PLUGIN_CLASS via init script")
applyPluginExternally(pluginManager, BUILD_SCAN_PLUGIN_CLASS)
if (geUrl) {
logger.lifecycle("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer, captureFileFingerprints: $geCaptureFileFingerprints")
logger.lifecycle("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
buildScan.server = geUrl
buildScan.allowUntrustedServer = geAllowUntrustedServer
}
buildScan.publishAlways()
if (isAtLeast(gePluginVersion, '2.1') && atLeastGradle5) {
if (isAtLeast(gePluginVersion, '3.7')) {
buildScan.capture.taskInputFiles = geCaptureFileFingerprints
} else {
buildScan.captureTaskInputFiles = geCaptureFileFingerprints
}
}
if (buildScan.metaClass.respondsTo(buildScan, 'setUploadInBackground', Boolean)) buildScan.uploadInBackground = buildScanUploadInBackground // uploadInBackground not available for build-scan-plugin 1.16
buildScan.value CI_AUTO_INJECTION_CUSTOM_VALUE_NAME, CI_AUTO_INJECTION_CUSTOM_VALUE_VALUE
if (isAtLeast(gePluginVersion, '2.1') && atLeastGradle5) {
logger.lifecycle("Setting captureFileFingerprints: $develocityCaptureFileFingerprints")
if (isAtLeast(gePluginVersion, '3.7')) {
buildScan.capture.taskInputFiles = develocityCaptureFileFingerprints
} else {
buildScan.captureTaskInputFiles = develocityCaptureFileFingerprints
}
}
}
if (geUrl && geEnforceUrl) {
pluginManager.withPlugin(BUILD_SCAN_PLUGIN_ID) {
afterEvaluate {
logger.lifecycle("Enforcing Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer, captureFileFingerprints: $geCaptureFileFingerprints")
logger.lifecycle("Enforcing Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
buildScan.server = geUrl
buildScan.allowUntrustedServer = geAllowUntrustedServer
}
if (isAtLeast(gePluginVersion, '2.1') && atLeastGradle5) {
if (isAtLeast(gePluginVersion, '3.7')) {
buildScan.capture.taskInputFiles = geCaptureFileFingerprints
} else {
buildScan.captureTaskInputFiles = geCaptureFileFingerprints
}
}
}
}
@@ -181,17 +175,18 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
applyPluginExternally(settings.pluginManager, DEVELOCITY_PLUGIN_CLASS)
eachDevelocityExtension(settings, DEVELOCITY_EXTENSION_CLASS) { ext ->
if (geUrl) {
logger.lifecycle("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer, captureFileFingerprints: $geCaptureFileFingerprints")
logger.lifecycle("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
ext.server = geUrl
ext.allowUntrustedServer = geAllowUntrustedServer
}
ext.buildScan.publishAlways()
ext.buildScan.uploadInBackground = buildScanUploadInBackground
if (isAtLeast(gePluginVersion, '2.1')) {
logger.lifecycle("Setting captureFileFingerprints: $develocityCaptureFileFingerprints")
if (isAtLeast(gePluginVersion, '3.7')) {
ext.buildScan.capture.taskInputFiles = geCaptureFileFingerprints
ext.buildScan.capture.taskInputFiles = develocityCaptureFileFingerprints
} else {
ext.buildScan.captureTaskInputFiles = geCaptureFileFingerprints
ext.buildScan.captureTaskInputFiles = develocityCaptureFileFingerprints
}
}
ext.buildScan.value CI_AUTO_INJECTION_CUSTOM_VALUE_NAME, CI_AUTO_INJECTION_CUSTOM_VALUE_VALUE
@@ -200,16 +195,9 @@ if (GradleVersion.current() < GradleVersion.version('6.0')) {
if (geUrl && geEnforceUrl) {
eachDevelocityExtension(settings, DEVELOCITY_EXTENSION_CLASS) { ext ->
logger.lifecycle("Enforcing Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer, captureFileFingerprints: $geCaptureFileFingerprints")
logger.lifecycle("Enforcing Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
ext.server = geUrl
ext.allowUntrustedServer = geAllowUntrustedServer
if (isAtLeast(gePluginVersion, '2.1')) {
if (isAtLeast(gePluginVersion, '3.7')) {
ext.buildScan.capture.taskInputFiles = geCaptureFileFingerprints
} else {
ext.buildScan.captureTaskInputFiles = geCaptureFileFingerprints
}
}
}
}