在 GitHub 存储库上显示 Jenkins 构建的当前状态 [英] Show current state of Jenkins build on GitHub repo

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

问题描述

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

我使用 Jenkins 运行持续集成构建.在每次提交之后,它确保在最终生成文档和发布包之前,一切都经过编译,并执行单元和集成测试.

仍然存在无意中提交破坏构建的内容的风险.访问 GitHub 项目页面的用户最好知道当前 master 处于该状态.

解决方案

好的,下面介绍如何设置 Jenkins 以设置 GitHub 构建状态.这假设您已经将 Jenkins 与 GitHub 插件配置为在每次推送时进行构建.

  1. 转到 GitHub,登录,转到设置个人访问令牌,点击生成新令牌.>

  2. 检查repo:status(我不确定这是否必要,但我做到了,而且对我有用).

  3. 生成令牌,复制它.

  4. 确保您要使用的 GitHub 用户是存储库协作者(对于私有存储库),或者是对您要构建的存储库具有推送和拉取访问权限(对于组织存储库)的团队成员.

  5. 转到您的 Jenkins 服务器,登录.

  6. 管理 Jenkins配置系统
  7. GitHub Web Hook 下选择 让 Jenkins 自动管理钩子 URL,然后指定您的 GitHub 用户名您在第 3 步中获得的 OAuth 令牌.

  8. 验证它是否与测试凭据按钮一起使用.保存设置.

  9. 找到 Jenkins 作业并将在 GitHub 提交时设置构建状态添加到构建后步骤

就是这样.现在进行测试构建并转到 GitHub 存储库以查看它是否有效.点击主存储库页面中的分支以查看构建状态.

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

Is there a way to show 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:

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

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