简体   繁体   English

如何使Jenkins构建推送代码并从Github获取请求

[英]How to make Jenkins build pushed code and pull requests from Github

I'm trying to find the right configuration so Jenkins starts a job when: 我正在尝试找到正确的配置,以便Jenkins在以下情况下开始工作:

1. code is pushed to Github
2. a pull request it made

I've found the Github and Github Pull Request Builder plugins to be very helpful, but I cannot get both #1 and #2 working concurrently. 我发现Github和Github Pull Request Builder插件非常有用,但我不能让#1和#2同时工作。

It may have to do with the refspec I set in the Source Code Management section. 它可能与我在源代码管理部分中设置的refspec有关。 #1 requires a refspec of +refs/heads/*:refs/remotes/origin/* while #2 requires a refspec of +refs/pull/*:refs/remotes/origin/pr/* . #1需要refspec +refs/heads/*:refs/remotes/origin/*而#2需要refspec +refs/pull/*:refs/remotes/origin/pr/*

I've tried using two repositories within the same section, but only one or the other builds, not both. 我尝试在同一部分中使用两个存储库,但只使用一个或另一个构建,而不是两个。

Is there a plugin or a specific configuration I can use that will build both pushes and pull requests? 是否有插件或我可以使用的特定配置将构建推送和拉取请求?

You can specify both refspecs by simply separating them with a space: 您可以通过简单地用空格分隔它们来指定两个refspec:

+refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/*

...as described here: https://git-scm.com/book/en/v2/Git-Internals-The-Refspec ......如下所述: https//git-scm.com/book/en/v2/Git-Internals-The-Refspec

Then configure multiple branch specifiers. 然后配置多个分支说明符。 I have: 我有:

*/master
${sha1}
:refs/heads/v\d*\.\d*

This builds, PRs, master and my release candidate branches. 这构建,PR,主和我的发布候选分支。

if you are trying to setup Both in one job then you may have to change your requirement little bit. 如果你试图在一个工作中设置两个,那么你可能需要稍微改变你的要求。

Either You create 2 jobs in same jenkins for different work. 您可以在同一个jenkins中为不同的工作创建2个工作。
OR Use pull request builder and set configuration to merge the code after build, this way you achieve both. 或者使用pull request builder并设置配置以在构建后合并代码,这样就可以实现两者。

If your repo have pushes other than pull request then you will have to create 2 jobs. 如果您的仓库已推送除拉动请求以外的其他仓库,那么您将必须创建2个工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jenkins:为Github Pull请求构建合并提交 - Jenkins: Build merge commit for Github Pull requests jenkins为几个项目构建github pull请求 - jenkins build github pull requests for few projects Jenkins在GitHub Pull请求上构建状态图标 - Jenkins build status icons on GitHub Pull requests 如何从 Github 拉取请求中删除 Jenkins 构建状态 - How to remove Jenkins build status from Github Pull Request 当更改被推送到Github时,无法使Jenkins触发构建 - not been able to make Jenkins trigger a build when changes are pushed to Github 如何使用Jenkins CI构建推送到github的新分支? - How to build the new branch pushed to github using Jenkins CI? Jenkins 项目检查来自多个 GitHub 存储库的拉取请求 - Jenkins project that checks pull requests from multiple GitHub repositories 如何制作由拉取请求触发的 Jenkins 管道以构建 Github 项目中的所有存储库 - How to make a Jenkins pipeline triggered by a pull request to build all the repositories in a Github project 将代码更改推送到 GitHub 时如何触发 Jenkins 多分支管道 - How to trigger a Jenkins multibranch pipeline when code change is pushed to GitHub Jenkins与Github Organization集成:在打开的拉取请求上,仅对拉取请求运行构建,对分支不运行 - Jenkins integrating with Github Organization: on opened pull requests, only run build for pull request NOT for branches
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM