Git environment variables for use in executing Jenkins shell scripts

孤街醉人 提交于 2019-11-29 03:53:54

Ok I cracked this one myself.

To see all environment variables available add to the Execute shell field:

printenv

Console output will then show all the available vars.

Marcus Kosek

Please also have a look at: How can I access the last built revision according to jenkins?

The part with the env-vars url was really helpful:

Lastly, to see a less comprehensive list of available environment variables, you can also just go to this url: http://[your-jenkins-domain-and-port]/env-vars.html

Similarly you could just echo them out:

echo GIT_COMMIT %GIT_COMMIT% 
echo GIT_BRANCH %GIT_BRANCH%

Here's a quick Jenkins Git configuration tutorial on the Git environment variables topic that uses the Jenkins Git configuration described in the image.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!