简体   繁体   English

使用Jenkins接收提交ID(GitHub插件)

[英]Receiving the commit id with Jenkins (GitHub plugin)

When we push some changes to github we can use Github services to trigger a build. 当我们将一些更改推送到github时,我们可以使用Github服务来触发构建。 Does the service provide the commit id? 该服务是否提供了提交ID?

Do you know how I can get that information? 你知道我怎么能得到这些信息吗?

I need the commit it to trigger the build for that specific id. 我需要提交它来触发该特定id的构建。 (Passing the commit id in the field "Branch Specifier (blank for 'any') "). (在“分支说明符”字段中传递提交ID(“任何”为空)“)。

As described here git plugin but seems I'm not receiving the commit id from git. 正如这里所描述的git插件,但似乎我没有从git收到提交ID。

I see my commit id in the post build actions, but not at the moment of the cheking out the code. 我在post构建操作中看到了我的提交ID,但是在检查代码时没有看到。

Thanks in advance. 提前致谢。

If you're using the Git Plugin ( https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin ) to check out your code in Jenkins, then you should be able access the GIT_COMMIT environment variable during any build steps. 如果您使用Git插件( https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin )检查Jenkins中的代码,那么您应该能够在任何构建期间访问GIT_COMMIT环境变量脚步。

There are other useful environment variables defined as well (GIT_BRANCH, GIT_PREVIOUS_COMMIT, etc.) that you may find helpful. 还定义了其他有用的环境变量(GIT_BRANCH,GIT_PREVIOUS_COMMIT等),您可能会发现它们很有帮助。

The GitHub webhooks UI doesn't provide the possibility to pass in parameters to the /git/notifyCommit URL, such as the commit SHA1. GitHub webhooks UI不提供将参数传递给/git/notifyCommit URL的可能性,例如提交SHA1。

There is however the GitHub service "Jenkins (GitHub plugin)" which passes a JSON payload to Jenkins for each commit, containing a bunch of information, including the commit SHA1. 然而,GitHub服务“Jenkins(GitHub插件)”为每次提交将JSON有效负载传递给Jenkins,其中包含一堆信息,包括提交SHA1。

If you enable, under Build Triggers, the "Build when a change is pushed to GitHub" option, you may get the behaviour you're looking for. 如果在“构建触发器”下启用“将更改推送到GitHub时构建”选项,则可能会获得您正在寻找的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM