-
Notifications
You must be signed in to change notification settings - Fork 40.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
git branch captured in the build scan is wrong #19614
Comments
@wilkinsona Hopefully of interest concourse/git-resource#198 |
What about mapping --- a/gradle/build-scan-user-data.gradle
+++ b/gradle/build-scan-user-data.gradle
@@ -36,6 +36,9 @@ void addGitMetadata() {
link 'Git commit build scans', customValueSearchUrl([(commitIdLabel): gitCommitId])
}
if (gitBranchName) {
+ // Concourse checks out master in detached HEAD state.
+ // See (https://github.com/concourse/git-resource/issues/198)
+ gitBranchName = 'HEAD'.equals(gitBranchName) ? 'master' : gitBranchName
tag gitBranchName
value 'Git branch', gitBranchName
} |
I'm not sure it's only |
It's only |
what if we fetch the branch name from if (gitBranchName) {
if (gitBranchName == "HEAD") {
def originBranchName = execAndGetStdout('git', 'rev-parse', '--abbrev-ref', 'origin/HEAD')
if (originBranchName.startsWith("origin/")) {
originBranchName = originBranchName.substring("origin/".size())
}
if (originBranchName) {
gitBranchName = originBranchName
}
}
tag gitBranchName
value 'Git branch', gitBranchName
} ? Sorry for poor code quality, I just want to express the idea. |
Interesting idea, @Maxim-Nazarenko. Thanks. That'll work while Gradle is only used on master but I don't think it'll work once we've branched 2.3.x. This is only a problem on CI and we already have the name of the branch there as a parameter. We could pass it into the job as an environment variable and then use it to set |
Closing in favor of PR #19658 |
It's captured as
HEAD
. I suspect it may be a side-effect of how the Concourse git resource checks out the code.The text was updated successfully, but these errors were encountered: