Reputation: 4270
I'm working on a project which uses jenkins for ci. I have to validate Github PR and update multiple checks. I'm using the Github Pull Request Builder Plugin. 1. linting the code 2. running unit test 3. code coverage
I want to github display the 3 status checks differently? Despite the 3 builds reporting status to github, github just displays "1 pending check" or "1 status check completed successfully".
I didn't find a proper solution for this without being able develop or script for the functionality. Is there any plugin or a way to achieve this.
I want this happen using only one Jenkins job
I have tried writing shell scripts to update the checks in github its reponse with success message but the PR is not update with the statuses.
curl -XPOST -H "Authorization: token XXXXXXXXXXXXXXXXXXXXXXXXXXXX" https://api.github.com/repos/org/reponame/statuses/$(git rev-parse HEAD) -d '{
"state": "success",
"target_url": "${BUILD_URL}",
"description": "All tests were passed!",
"context": "jenkins-ci-unit-test"
}'
Response
% Total % Received % Xferd Average Speed Time Time Time Current
05:15:26 Dload Upload Total Spent Left Speed
05:15:26
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 1528 100 1350 100 178 8318 1096 --:--:-- --:--:-- --:--:-- 8333
05:15:26 {
05:15:26 "url": "https://api.github.com/repos/org/reponame/statuses/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
05:15:26 "id": 333333333,
05:15:26 "state": "success",
05:15:26 "description": "All tests were passed!",
05:15:26 "target_url": "http://xxx.xxxxx.com/job/job1",
05:15:26 "context": "jenkins-ci-unit-test",
05:15:26 "created_at": "2016-11-29T10:15:26Z",
05:15:26 "updated_at": "2016-11-29T10:15:26Z",
05:15:26 "creator": {
05:15:26 .......
05:15:26 }
05:15:26 }
Upvotes: 0
Views: 1777
Reputation: 364
The commit hash you use to update the check is wrong. It should be the last current commit of the PR.. You need to get the correct commit hash by calling the following github API end point https://api.github.com/repos/orgname/reponame/pulls/prno
Upvotes: 1
Reputation: 21
Try using
git rev-list --max-count=2 HEAD | tail -n 1
instead of
git rev-parse HEAD
So it takes the previous commit value
Upvotes: 1