-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Improve build scan metadata #44247
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
Merged
Merged
Improve build scan metadata #44247
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5c40e43
Improve build scan metadata
mark-vieira 114f364
Use correct environment variable for jenkins build link
mark-vieira 13c070e
Improve handling of pull request builds
mark-vieira d30d251
Fix syntax error
mark-vieira 64c0055
Handle detached branch state better
mark-vieira 47a1ca0
Auto-accept build scan terms of service when running in CI
mark-vieira 87a306a
Add Jenkins worker node labels as build scan custom values
mark-vieira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import nebula.plugin.info.scm.ScmInfoExtension | ||
|
||
buildScan { | ||
// Accept Gradle ToS when project property org.elasticsearch.acceptScanTOS=true | ||
if (Boolean.valueOf(project.findProperty('org.elasticsearch.acceptScanTOS') ?: "false")) { | ||
termsOfServiceUrl = 'https://gradle.com/terms-of-service' | ||
termsOfServiceAgree = 'yes' | ||
} | ||
|
||
// Jenkins-specific build scan metadata | ||
if (System.getenv('JENKINS_URL')) { | ||
tag 'CI' | ||
tag System.getenv('JOB_NAME') | ||
link 'Jenkins Build', System.getenv('BUILD_URL') | ||
|
||
// Capture changes included in this CI build except for pull request builds | ||
if (System.getenv('GIT_COMMIT') && System.getenv('ROOT_BUILD_CAUSE_GHPRBCAUSE') == null) { | ||
background { | ||
def changes = "git diff --name-only ${System.getenv('GIT_PREVIOUS_COMMIT')}..${System.getenv('GIT_COMMIT')}".execute().text.trim() | ||
value 'Git Changes', changes | ||
} | ||
} | ||
} else { | ||
tag 'LOCAL' | ||
} | ||
|
||
// Add SCM information | ||
def scmInfo = project.extensions.findByType(ScmInfoExtension) | ||
if (scmInfo && scmInfo.change && scmInfo.branch) { | ||
value 'Git Commit ID', scmInfo.change | ||
// Don't tag the branch if we are in a detached head state | ||
if (scmInfo.branch ==~ /[0-9a-f]{5,40}/ == false) { | ||
value 'Git Branch', scmInfo.branch | ||
tag scmInfo.branch | ||
} | ||
link 'Source', "https://github.com/elastic/elasticsearch/commit/${scmInfo.change}" | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could check if this contains
elastic.co
to make sure it's our CI and accept the terms of service if so so no additional property needs to be passed in Jenkins.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually we'll be pushing scans to Gradle Enterprise which doesn't require accepting the ToS so I think that might be unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone ahead and implemented this. I agree, it'd be nice to ditch the need to pass the ToS param in Jenkins for the time being.