Quantcast
Channel: How do I get the current branch name in Git? - Stack Overflow
Viewing all articles
Browse latest Browse all 96

Answer by user3405314 for How do I get the current branch name in Git?

$
0
0

if you run in Jenkins, you can use GIT_BRANCH variable as appears here:https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin

The git plugin sets several environment variables you can use in your scripts:

  1. GIT_COMMIT - SHA of the current

  2. GIT_BRANCH - Name of the branch currently being used, e.g. "master"or "origin/foo"

  3. GIT_PREVIOUS_COMMIT - SHA of the previous built commit from the samebranch (the current SHA on first build in branch)

  4. GIT_URL - Repository remote URL

  5. GIT_URL_N - Repository remote URLs when there are more than 1remotes, e.g. GIT_URL_1, GIT_URL_2

  6. GIT_AUTHOR_EMAIL - Committer/Author Email

  7. GIT_COMMITTER_EMAIL - Committer/Author Email


Viewing all articles
Browse latest Browse all 96

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>