Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins set github commit status not working

Tags:

git

jenkins

I see that the command is being called in the logs but in GitHub it does not display the status.

[Set GitHub commit status (universal)] PENDING on repos [] (sha:47ccf20) with context:api

The webhook-url is working correctly and is notifying Jenkins of when to build.

I also have the GitHub server setup and test connection is working.

Any ideas about what I might be missing in the setup?

I followed the steps in this question but still not getting anything to show in github: Show current state of Jenkins build on GitHub repo

like image 206
Michael St Clair Avatar asked Feb 16 '17 02:02

Michael St Clair


People also ask

What is GitHub commit status?

The Commit status API allows external services to mark commits with an error , failure , pending , or success state, which is then reflected in pull requests involving those commits.


2 Answers

if you're following the steps in the link you shared, you might have missed a critical step after step 9 (Set Github commit status) which is to select the second option in the Status result options in the What section as shown below:

Post build action -> Set Github commit status (universal)

This would allow you to send the default status messages (error, failed, success, pending) for each build. Selecting the first option would require you to manually define which status you want to send back (which is none by default and might explain why you're not receiving anything).

Also be sure to verify that your payload url in Webhook section on Github is configured correctly with your generated token. I think you've done that well anyway.

Payload Configuration

You can select Let me choose individual events to have more control over what Jenkins can send but be sure to make sure repo:status option is ticked. Hope that helps.

like image 69
O'Kamiye Avatar answered Sep 20 '22 11:09

O'Kamiye


For debugging, Use below CLI command to check whether your access token is able to set the status in GitHub for any dummy_test PR.

curl "https://api.github.com/repos/[organization name]/[repo name]/statuses/[commit id]?access_token=[GitHub access token]" -H "Content-Type: application/json"   -X POST -d "{\"state\": \"success\", \"description\": \"Build Successful \", \"target_url\": \"[jenkins job url]\", \"context\": \"[Job name]\" }"

PS: Remove square braces

like image 27
kolukuri Avatar answered Sep 22 '22 11:09

kolukuri