有没有办法在我项目的GitHub Readme.md上显示Jenkins构建状态?

我使用Jenkins运行持续集成构建。在每次提交之后,它确保在最终生成文档和发布包之前,所有内容都已编译,并执行单元和集成测试。

仍然存在无意中提交一些破坏构建的内容的风险。对于访问GitHub项目页面的用户来说,知道当前主程序处于该状态是很好的。


当前回答

还有这个插件,它会给你一个徽章的url,你可以在你的README中发布。Md,看起来像这样

https://wiki.jenkins-ci.org/display/JENKINS/Embeddable+Build+Status+Plugin

其他回答

我所做的很简单:

Install the Hudson Post Task Plugin Create a Personal Access Token here : https://github.com/settings/tokens Add a Post Task Plugin that always put success 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!\" }" Add a Post Task Plugin that will put failure if "marked build as failure" 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!\" }" You can also add a call to pending at the beginning of tests 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!\" }"

这个插件应该可以工作:https://wiki.jenkins-ci.org/display/JENKINS/Embeddable+Build+Status+Plugin

您应该能够将这样的徽章嵌入到README中。md文件:

如果你在Jenkins上安装了Github插件,你可以在Post build操作中这样做:

我按照亚历克斯的指示做了,而且成功了。

但是,对于GitHub企业,在将服务器添加到Jenkins时需要修改API URL。

例如,如果您的公司是creditcard.com,您的URL将是

https://github.creditcard.com/api/v3/

还有这个插件,它会给你一个徽章的url,你可以在你的README中发布。Md,看起来像这样

https://wiki.jenkins-ci.org/display/JENKINS/Embeddable+Build+Status+Plugin