[英]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.