内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用
有没有办法在我的项目的GitHub Readme.md上显示Jenkins构建状态?
我使用Jenkins来运行持续集成构建。在每次提交之后,它会确保编译所有内容,并执行单元和集成测试,然后才能最终生成文档和发布包。
好的,你可以通过设置Jenkins来设置GitHub的构建状态。假设你已经将Jenkins与GitHub插件配置为在每次推送时进行构建。
而已。现在做一个测试构建并转到GitHub存储库以查看它是否工作。点击主资源库页面中的分支以查看构建状态。
你应该看到绿色的选中标记:
我做的很简单:
curl -XPOST -H "Authorization: token OAUTH TOKEN" https://api.github.com/repos/:organization/:repos/statuses/$(git rev-parse HEAD) -d "{ \"state\": \"success\", \"target_url\": \"${BUILD_URL}\", \"description\": \"The build has succeeded!\" }"
curl -XPOST -H "Authorization: token OAUTH TOKEN" https://api.github.com/repos/:organization/:repos/statuses/$(git rev-parse HEAD) -d "{ \"state\": \"failure\", \"target_url\": \"${BUILD_URL}\", \"description\": \"The build has failed!\" }"
curl -XPOST -H "Authorization: token OAUTH TOKEN" https://api.github.com/repos/:organization/:repos/statuses/$(git rev-parse HEAD) -d "{ \"state\": \"pending\", \"target_url\": \"${BUILD_URL}\", \"description\": \"The build is pending!\" }"