简体   繁体   中英

Jenkins set github commit status not working

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

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:

构建后操作 -> 设置 Github 提交状态(通用)

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.

负载配置

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.

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

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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