Oldek Oldek - 1 year ago 119
Git Question

Git Variables in Jenkins Workflow plugin

I'd like to access git variables such as GIT_COMMIT and GIT_BRANCH when I have checked out a repository from git further down in the build stream. Currently I find no available variable to access these two parameters.

node {
git git+ssh://git.com/myproject.git

Is such variables available and in case, where would I find them. I don't mind if they are available through some groovy variables or wherever, just that I can access them.

Maybe I lack the debugging skills in Groovy and this is easy to find, but I just can't find it with my limited skills.

Answer Source

I good way to fix this for now is to use the Multi-branch pipeline, and it might be good to know that Bitbucket and Github have plugins in Jenkins that sets up an organisation and autodiscovers new projects. This works natively then with env.GIT_BRANCH

For commit ID I would suggest what @mkobit wrote above.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download