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

Set the the value of GIT_BRANCH when kicking off builds #170

Merged
merged 1 commit into from
Sep 15, 2014

Conversation

codemercenary
Copy link
Contributor

Allows users to refer to the original branch name when rewriting build descriptors by using ${GIT_BRANCH}

@ShonM
Copy link

ShonM commented Aug 22, 2014

Super valuable!

@DavidTanner
Copy link
Collaborator

This is already set by ${ghprbSourceBranch}, is there any reason to add another variable?

@codemercenary
Copy link
Contributor Author

If you set GIT_BRANCH, then I can use GIT_BRANCH when I rewrite the build name in the log. Most of the environment variables aren't normally available in the "set branch name" option.

@intel352
Copy link

Setting GIT_BRANCH would allow scripts to be able to function regardless of whether the initiator was ghprb or a standard build. It would allow for a greater consistency in build scripting (and would read better for the purpose of tracking the build details).

@codemercenary
Copy link
Contributor Author

@intel352 I didn't think of that, good point.

I actually did try to refer to ghprbSourceBranch when building, I found the name of that variable when I was making this change in particular. I found that it didn't work properly which is why I went back and added this one.

@DavidTanner
Copy link
Collaborator

Does the git plugin also set this value? If so, then will it be overriding the value when the build is started by ghprb? I am not familiar with the process is why I ask.

@DavidTanner
Copy link
Collaborator

There are two places that the git plugin sets that variable. For my current build it is set as detached when using ghprb
https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitSCM.java#L941
https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitSCM.java#L1058

@codemercenary
Copy link
Contributor Author

The git plugin tries to set this value before GhprbTrigger.startJob is invoked. We're overriding it. And obviously we're getting a detached head because a pull request commit isn't actually contained in any branch.

Potentially we could detect the detached state and only override in that case, though I am inclined to say that there's not really any circumstance that the git plugin will have more correct information than we do about what branch is being built.

@codemercenary
Copy link
Contributor Author

Man, this is the reason I love github. I thought this pull request would get no activity, and we're here having a conversation about it a month later and it's still relevant.

DavidTanner added a commit that referenced this pull request Sep 15, 2014
Set the the value of GIT_BRANCH when kicking off builds
@DavidTanner DavidTanner merged commit a6d794f into janinko:master Sep 15, 2014
@codemercenary
Copy link
Contributor Author

WooT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants