有没有办法在我项目的GitHub Readme.md上显示Jenkins构建状态?
我使用Jenkins运行持续集成构建。在每次提交之后,它确保在最终生成文档和发布包之前,所有内容都已编译,并执行单元和集成测试。
仍然存在无意中提交一些破坏构建的内容的风险。对于访问GitHub项目页面的用户来说,知道当前主程序处于该状态是很好的。
有没有办法在我项目的GitHub Readme.md上显示Jenkins构建状态?
我使用Jenkins运行持续集成构建。在每次提交之后,它确保在最终生成文档和发布包之前,所有内容都已编译,并执行单元和集成测试。
仍然存在无意中提交一些破坏构建的内容的风险。对于访问GitHub项目页面的用户来说,知道当前主程序处于该状态是很好的。
当前回答
我按照亚历克斯的指示做了,而且成功了。
但是,对于GitHub企业,在将服务器添加到Jenkins时需要修改API URL。
例如,如果您的公司是creditcard.com,您的URL将是
https://github.creditcard.com/api/v3/
其他回答
加上这个答案,也加上这个答案,他们已经回答了这个问题,但没有给我们一个关于这个问题的正确的直觉
我的直觉是这样的:
We need to add status to our GitHub commit, this status is based upon the results of our Jenkins build. To do this we need to give Jenkins access to the GitHub API not to the repo, we do this through OAuth we can create the token going to the GH settings -> Developer settings -> Personal access tokens then for public GH repo just check repo:status, and for private repo check the whole repo section After creating your access token you need to add it to ur Jenkins server: Copy and paste the access token to the GitHub plugin section settings, under ur Jenkins configurations Create a GH server it defaults to api.github.com and add the access token as a secret text credentials. The last step is to add a post build settings when U create ur pipeline.
资源:
以下是YT视频的一个部分,他在其中介绍了上述步骤。 阅读OAuth
如果你在Jenkins上安装了Github插件,你可以在Post build操作中这样做:
好的,下面是如何设置Jenkins来设置GitHub构建状态。这里假设你已经有了Jenkins和GitHub插件,可以在每次推送时进行构建。
Go to GitHub, log in, go to Settings, Developer Settings, Personal access tokens and click on Generate new token. Check repo:status (I'm not sure this is necessary, but I did it, and it worked for me). Generate the token, copy it. Make sure the GitHub user you're going to use is a repository collaborator (for private repos) or is a member of a team with push and pull access (for organization repos) to the repositories you want to build. Go to your Jenkins server, log in. Manage Jenkins → Configure System Under GitHub Web Hook select Let Jenkins auto-manage hook URLs, then specify your GitHub username and the OAuth token you got in step 3. Verify that it works with the Test Credential button. Save the settings. Find the Jenkins job and add Set build status on GitHub commit to the post-build steps
就是这样。现在做一个测试构建,去GitHub存储库看看它是否工作。单击主存储库页面中的Branches查看构建状态。
你应该看到绿色的复选标记:
我按照亚历克斯的指示做了,而且成功了。
但是,对于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