显示Jenkins基于GitHub回购的当前状态 [英] Show current state of Jenkins build on GitHub repo

查看:300
本文介绍了显示Jenkins基于GitHub回购的当前状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

解决方案

好的,您可以设置Jenkins来设置GitHub构建状态。假设您已经将Jenkins与GitHub插件配置为在每次推送时进行构建。


  1. 转到GitHub,log请转到设置个人访问令牌,然后点击生成新令牌


  2. 检查 repo:status (我不确定这是否有必要,但是我做到了,并且对我有用)。 src =https://i.stack.imgur.com/STiUm.pngalt =GitHub令牌生成截图>

  3. 生成令牌,复制它。 确保您要使用的GitHub用户是存储库协作者(用于私人回购)或者是推送访问权(用于组织回购)到您想要构建的存储库。
  4. li>
  5. 管理Jenkins GitHub Web Hook 下,选择让Jenkins自动管理挂钩网址配置系统
  6. 然后在步骤3中指定您的GitHub 用户名 OAuth标记


  7. 验证它是否有效使用测试凭据按钮。 保存设置。


  8. 找到Jenkins作业并将在GitHub commit上设置构建状态后制作步骤

  9. b就是这样。现在做一个测试构建并转到GitHub存储库以查看它是否工作。点击主资源库页面中的分支以查看构建状态。



    您应该看到绿色的复选标记:




    Is there a way to show the the Jenkins build status on my project's GitHub Readme.md?

    I use Jenkins to run continuous integration builds. After each commit it ensures that everything compiles, as well as executes unit and integration tests, before finally producing documentation and release bundles.

    There's still a risk of inadvertently committing something that breaks the build. It would be good for users visiting the GitHub project page to know the current master is in that state.

    解决方案

    Ok, here's how you can set up Jenkins to set GitHub build statuses. This assumes you've already got Jenkins with the GitHub plugin configured to do builds on every push.

    1. Go to GitHub, log in, go to Settings, Personal access tokens, click on Generate new token.

    2. Check repo:status (I'm not sure this is necessary, but I did it, and it worked for me).

    3. Generate the token, copy it.

    4. 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.

    5. Go to your Jenkins server, log in.

    6. Manage JenkinsConfigure System
    7. 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.

    8. Verify that it works with the Test Credential button. Save the settings.

    9. Find the Jenkins job and add Set build status on GitHub commit to the post-build steps

    That's it. Now do a test build and go to GitHub repository to see if it worked. Click on Branches in the main repository page to see build statuses.

    You should see green checkmarks:

    这篇关于显示Jenkins基于GitHub回购的当前状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆