13

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

Community
  • 1
  • 1
Michael St Clair
  • 5,937
  • 10
  • 49
  • 75

4 Answers4

27

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.

O'Kamiye
  • 456
  • 4
  • 6
  • 3
    "make sure repo:status option is ticked" <- why does this matter? Aren't webhooks only pokes from GitHub? – Fitzy Dec 02 '20 at 21:20
3

I was experiencing this issue even after selecting the option that @O'Kamiye mentioned. I realized my problem was that my Jenkins Github server wasn't running after seeing this thread. To summarize:

The GitHubCommitStatusSetter requires that the Git Server is defined under Manage Jenkins > Configure System > GitHub > GitHub Servers. Otherwise the GitHubCommitStatusSetter is not able to resolve the repository name properly...

After following the steps, the issue was resolved. Hope this helps.

gfdb
  • 311
  • 2
  • 9
2

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

kolukuri
  • 317
  • 2
  • 8
0

It also wasn't working for me even after following all the answers in OP's link.

The problem was the scope of the personal access token that I had generated. It needs the Full control of private repositories access, and NOT only the repo:status.

Roger Oba
  • 1,292
  • 14
  • 28