Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Build Scan conditional publication #38102

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .mvn/gradle-enterprise-custom-user-data.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ if(session?.getRequest()?.getBaseDirectory() != null) {
if(!publish) {
// do not publish a build scan for test builds
log.debug("Disabling build scan publication for " + session.getRequest().getBaseDirectory())

// change storage location on CI to avoid Develocity scan dumps with disabled publication to be captured for republication
if (System.env.GITHUB_ACTIONS) {
try {
def storageLocationTmpDir = java.nio.file.Files.createTempDirectory(java.nio.file.Paths.get(System.env.RUNNER_TEMP), "buildScanTmp").toAbsolutePath()
log.debug('Update storage location to ' + storageLocationTmpDir)
gradleEnterprise.setStorageDirectory(storageLocationTmpDir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this instance global to the build (or even to the module at hand)? Because if so, we would need to set it to the default value in the publish == true case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The storage directory is set to .m2/.gradle-enterprise when the extension is configured on each build startup

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this script is executed independently and gradleEnterprise isn't global to the whole build and doesn't leak?

I was worried about gradleEnterprise being global for the whole build and this case could then happen:

  • module1 (storageDirectory == default)
  • module2 (storageDirectory == default)
  • test build in module 2 (storageDirectory == tmp dir)
  • module3 (storageDirectory == tmp dir while we would like it to be the default)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I logged the storage directory and can confirm that it is reset on each and every build to the default value (even after a previous build setting it to a temporary directory)

} catch (IOException e) {
log.error('Temporary storage location directory cannot be created, the Build Scan will be published', e)
}
}
}
}
buildScan.publishAlwaysIf(publish)
Expand Down
Loading