mirror of
https://github.com/gradle/actions.git
synced 2025-08-18 14:51:28 +08:00
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:
parent
393df4bfa2
commit
c276584302
@ -94,7 +94,7 @@ def geUrl = getInputParam('develocity.url')
|
|||||||
def geAllowUntrustedServer = Boolean.parseBoolean(getInputParam('develocity.allow-untrusted-server'))
|
def geAllowUntrustedServer = Boolean.parseBoolean(getInputParam('develocity.allow-untrusted-server'))
|
||||||
def geEnforceUrl = Boolean.parseBoolean(getInputParam('develocity.enforce-url'))
|
def geEnforceUrl = 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 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 gePluginVersion = 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 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")
|
logger.lifecycle("Applying $BUILD_SCAN_PLUGIN_CLASS via init script")
|
||||||
applyPluginExternally(pluginManager, BUILD_SCAN_PLUGIN_CLASS)
|
applyPluginExternally(pluginManager, BUILD_SCAN_PLUGIN_CLASS)
|
||||||
if (geUrl) {
|
if (geUrl) {
|
||||||
logger.lifecycle("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer, captureFileFingerprints: $geCaptureFileFingerprints")
|
logger.lifecycle("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
|
||||||
buildScan.server = geUrl
|
buildScan.server = geUrl
|
||||||
buildScan.allowUntrustedServer = geAllowUntrustedServer
|
buildScan.allowUntrustedServer = geAllowUntrustedServer
|
||||||
}
|
}
|
||||||
buildScan.publishAlways()
|
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
|
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
|
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) {
|
if (geUrl && geEnforceUrl) {
|
||||||
pluginManager.withPlugin(BUILD_SCAN_PLUGIN_ID) {
|
pluginManager.withPlugin(BUILD_SCAN_PLUGIN_ID) {
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
logger.lifecycle("Enforcing Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer, captureFileFingerprints: $geCaptureFileFingerprints")
|
logger.lifecycle("Enforcing Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
|
||||||
buildScan.server = geUrl
|
buildScan.server = geUrl
|
||||||
buildScan.allowUntrustedServer = geAllowUntrustedServer
|
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)
|
applyPluginExternally(settings.pluginManager, DEVELOCITY_PLUGIN_CLASS)
|
||||||
eachDevelocityExtension(settings, DEVELOCITY_EXTENSION_CLASS) { ext ->
|
eachDevelocityExtension(settings, DEVELOCITY_EXTENSION_CLASS) { ext ->
|
||||||
if (geUrl) {
|
if (geUrl) {
|
||||||
logger.lifecycle("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer, captureFileFingerprints: $geCaptureFileFingerprints")
|
logger.lifecycle("Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer")
|
||||||
ext.server = geUrl
|
ext.server = geUrl
|
||||||
ext.allowUntrustedServer = geAllowUntrustedServer
|
ext.allowUntrustedServer = geAllowUntrustedServer
|
||||||
}
|
}
|
||||||
ext.buildScan.publishAlways()
|
ext.buildScan.publishAlways()
|
||||||
ext.buildScan.uploadInBackground = buildScanUploadInBackground
|
ext.buildScan.uploadInBackground = buildScanUploadInBackground
|
||||||
if (isAtLeast(gePluginVersion, '2.1')) {
|
if (isAtLeast(gePluginVersion, '2.1')) {
|
||||||
|
logger.lifecycle("Setting captureFileFingerprints: $develocityCaptureFileFingerprints")
|
||||||
if (isAtLeast(gePluginVersion, '3.7')) {
|
if (isAtLeast(gePluginVersion, '3.7')) {
|
||||||
ext.buildScan.capture.taskInputFiles = geCaptureFileFingerprints
|
ext.buildScan.capture.taskInputFiles = develocityCaptureFileFingerprints
|
||||||
} else {
|
} else {
|
||||||
ext.buildScan.captureTaskInputFiles = geCaptureFileFingerprints
|
ext.buildScan.captureTaskInputFiles = develocityCaptureFileFingerprints
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ext.buildScan.value CI_AUTO_INJECTION_CUSTOM_VALUE_NAME, CI_AUTO_INJECTION_CUSTOM_VALUE_VALUE
|
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) {
|
if (geUrl && geEnforceUrl) {
|
||||||
eachDevelocityExtension(settings, DEVELOCITY_EXTENSION_CLASS) { ext ->
|
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.server = geUrl
|
||||||
ext.allowUntrustedServer = geAllowUntrustedServer
|
ext.allowUntrustedServer = geAllowUntrustedServer
|
||||||
if (isAtLeast(gePluginVersion, '2.1')) {
|
|
||||||
if (isAtLeast(gePluginVersion, '3.7')) {
|
|
||||||
ext.buildScan.capture.taskInputFiles = geCaptureFileFingerprints
|
|
||||||
} else {
|
|
||||||
ext.buildScan.captureTaskInputFiles = geCaptureFileFingerprints
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,8 +234,11 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
|
|
||||||
then:
|
then:
|
||||||
outputContainsDevelocityPluginApplicationViaInitScript(result, testGradleVersion.gradleVersion)
|
outputContainsDevelocityPluginApplicationViaInitScript(result, testGradleVersion.gradleVersion)
|
||||||
outputContainsDevelocityConnectionInfo(result, mockScansServer.address.toString(), true, true)
|
outputContainsDevelocityConnectionInfo(result, mockScansServer.address.toString(), true)
|
||||||
outputMissesCcudPluginApplicationViaInitScript(result)
|
outputMissesCcudPluginApplicationViaInitScript(result)
|
||||||
|
if (testGradleVersion.gradleVersion >= GRADLE_5_X.gradleVersion) {
|
||||||
|
outputCaptureFileFingerprints(result, true)
|
||||||
|
}
|
||||||
|
|
||||||
and:
|
and:
|
||||||
outputContainsBuildScanUrl(result)
|
outputContainsBuildScanUrl(result)
|
||||||
@ -344,12 +347,18 @@ class TestDevelocityInjection extends BaseInitScriptTest {
|
|||||||
assert !result.output.contains(pluginApplicationLogMsg)
|
assert !result.output.contains(pluginApplicationLogMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
void outputContainsDevelocityConnectionInfo(BuildResult result, String geUrl, boolean geAllowUntrustedServer, boolean geCaptureFileFingerprints = false) {
|
void outputContainsDevelocityConnectionInfo(BuildResult result, String geUrl, boolean geAllowUntrustedServer) {
|
||||||
def geConnectionInfo = "Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer, captureFileFingerprints: $geCaptureFileFingerprints"
|
def geConnectionInfo = "Connection to Develocity: $geUrl, allowUntrustedServer: $geAllowUntrustedServer"
|
||||||
assert result.output.contains(geConnectionInfo)
|
assert result.output.contains(geConnectionInfo)
|
||||||
assert 1 == result.output.count(geConnectionInfo)
|
assert 1 == result.output.count(geConnectionInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void outputCaptureFileFingerprints(BuildResult result, boolean captureFileFingerprints) {
|
||||||
|
def captureFileFingerprintsInfo = "Setting captureFileFingerprints: $captureFileFingerprints"
|
||||||
|
assert result.output.contains(captureFileFingerprintsInfo)
|
||||||
|
assert 1 == result.output.count(captureFileFingerprintsInfo)
|
||||||
|
}
|
||||||
|
|
||||||
void outputContainsPluginRepositoryInfo(BuildResult result, String gradlePluginRepositoryUrl, boolean withCredentials = false) {
|
void outputContainsPluginRepositoryInfo(BuildResult result, String gradlePluginRepositoryUrl, boolean withCredentials = false) {
|
||||||
def repositoryInfo = "Develocity plugins resolution: ${gradlePluginRepositoryUrl}"
|
def repositoryInfo = "Develocity plugins resolution: ${gradlePluginRepositoryUrl}"
|
||||||
assert result.output.contains(repositoryInfo)
|
assert result.output.contains(repositoryInfo)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user