Reputation: 309
When we push some changes to github we can use Github services to trigger a build. Does the service provide the commit id?
Do you know how I can get that information?
I need the commit it to trigger the build for that specific id. (Passing the commit id in the field "Branch Specifier (blank for 'any') ").
As described here git plugin but seems I'm not receiving the commit id from git.
I see my commit id in the post build actions, but not at the moment of the cheking out the code.
Thanks in advance.
Upvotes: 6
Views: 25504
Reputation: 111625
The GitHub webhooks UI doesn't provide the possibility to pass in parameters to the /git/notifyCommit
URL, such as the commit 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.
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.
Upvotes: 0
Reputation: 328
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.
There are other useful environment variables defined as well (GIT_BRANCH, GIT_PREVIOUS_COMMIT, etc.) that you may find helpful.
Upvotes: 6