-
Notifications
You must be signed in to change notification settings - Fork 48
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
Use git log instead git rev-parse to get current branch #41
Comments
I agree, when deploying via travis it's useless - it always returns HEAD. |
I agree, when deploying via gitlab it's useless - it always returns HEAD. |
When building on CI servers, the value should come from specific environment variables (for more info see https://github.com/n0mer/gradle-git-properties/blob/master/src/main/groovy/com/gorylenko/properties/BranchProperty.groovy)
|
I use this configuration:
Which gives nicely formatted version strings no matter if you're currently on a tag, a branch, or worst-case a detached head, in which case it falls back to the short git hash. |
For Jenkins, the env var, "BRANCH_NAME", is only available for a multibranch project. And there are no "GIT_LOCAL_BRANCH" and "GIT_BRANCH" in Jenkins. I'm using Jenkins 2.303.2 |
git rev-parse --abbrev-ref HEAD
isn't very helpful, as it always returns HEAD when you're in detached HEAD state (i.e. when deploying via gitlab).I suggest using
git log -n 1 --pretty=%d HEAD
instead, in detached HEAD state it produces a more meaningful output:(HEAD, origin/sandbox/test_git_revision_plugin)
The text was updated successfully, but these errors were encountered: