Skip to content

Commit

Permalink
Merge pull request #34335 from jprinet/fix/disable-test-build-scans-p…
Browse files Browse the repository at this point in the history
…ublication

Disable build scan publication for test builds
  • Loading branch information
gsmet authored Jul 7, 2023
2 parents c5bfa12 + cf50a17 commit 6067699
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .mvn/gradle-enterprise-custom-user-data.groovy
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@

// Configure build scan publication
boolean publish = true
if(session?.getRequest()?.getBaseDirectory() != null) {
def testBuildPaths = [ '/target/codestart-test/', '/target/it/', '/target/test-classes/', '/target/test-project/']
publish = testBuildPaths.every {testBuildPath -> !session.getRequest().getBaseDirectory().contains(testBuildPath) }
if(!publish) {
// do not publish a build scan for test builds
log.debug("Disabling build scan publication for " + session.getRequest().getBaseDirectory())
}
}
buildScan.publishAlwaysIf(publish)
buildScan.publishIfAuthenticated()

// Add mvn command line
def mvnCommand = ''
Expand Down
12 changes: 4 additions & 8 deletions .mvn/gradle-enterprise.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
</server>
<buildScan>
<!-- adjust conditions ?
mvn gradle-enterprise:provision-access-key
mvn gradle-enterprise:provision-access-key
https://docs.gradle.com/enterprise/maven-extension/#publishing_based_on_criteria
-->
<!-- only publish test runs when failure (no option to completely avoid it)-->
<publish>#{basedir.contains('test-classes') ? 'ON_FAILURE' : 'ALWAYS'}</publish>
<!-- tag which builds are tests vs real -->
<tags>
<tag>#{basedir.contains('test-classes') ? 'TEST-BUILD' : 'MAIN-BUILD'}</tag>
</tags>
<!-- build scan publication is configured in gradle-enterprise-custom-user-data.groovy
to leverage options to disable build scan publication for test builds
-->
<obfuscation>
<!-- Don't share ip addresses-->
<ipAddresses>#{{'0.0.0.0'}}</ipAddresses>
Expand All @@ -23,7 +20,6 @@
</capture>
<!-- https://docs.gradle.com/enterprise/maven-extension/#manual_access_key_configuration -->
<backgroundBuildScanUpload>#{env['CI'] == null}</backgroundBuildScanUpload>
<publishIfAuthenticated>true</publishIfAuthenticated>
</buildScan>
<buildCache>
<local><enabled>false</enabled></local>
Expand Down

0 comments on commit 6067699

Please sign in to comment.