简体   繁体   English

针对特定分支Jenkins的投票SCM

[英]Poll SCM for a specific branch Jenkins

I have a Github project with many branches. 我有一个有很多分支的Github项目。

Example

master
staging
feature-1
feature-2

I have a Jenkins job that has the "Poll SCM" option enabled with the following cronjob (10 7,9,11,13,15,17,19 * * 1-5) 我有一个詹金斯工作,其中的“轮询SCM”选项已启用以下cronjob(10 7,9,11,13,15,17,19 * * 1-5)

However, this job will kick off when a change is made to master also. 但是,对母版进行更改时也会开始这项工作。

I want a Jenkins job to only kick off if a commit to the staging branch. 我希望Jenkins的工作仅在提交到暂存分支时才开始。

Here is an output of the polling logs 这是轮询日志的输出

Started on Nov 20, 2018 1:10:00 PM
no polling baseline in /var/jenkins_workspace/workspace/Staging-ALL-Deploy@libs/jenkins-pipeline-global-lib on 
Using strategy: Default
[poll] Last Built Revision: Revision efccc8e212470802d64537e0a5e710f9b5c063b6 (refs/remotes/origin/staging)
 > git --version # timeout=10
 > git ls-remote -h http://git.company.com/org/repo.git # timeout=10
Found 56 remote heads on http://git.company.com/org/repo.git
[poll] Latest remote head revision on refs/heads/staging is: efccc8e212470802d64537e0a5e710f9b5c063b6 - already built by 171
Using strategy: Default
[poll] Last Built Revision: Revision efccc8e212470802d64537e0a5e710f9b5c063b6 (refs/remotes/origin/staging)
 > git --version # timeout=10
 > git ls-remote -h http://git.company.com/org/repo.git # timeout=10
Found 56 remote heads on http://git.company.com/org/repo.git
[poll] Latest remote head revision on refs/heads/master is: 865459e59ef5f91fddbd7453d9f2205560327c44
Done. Took 0.46 sec
Changes found

Is this possible? 这可能吗?

Thanks John 谢谢约翰

You can set which branch you want to build with following way: 您可以通过以下方式设置要构建的分支:

Configure -> Source Code Management tab -> Branch to Build -> Branch specifier 配置->源代码管理选项卡->要构建的分支->分支说明符

just write staging in this section. 只需在本节中编写阶段。 Then go to Build Triggers tab, select GitHub hook trigger for GITScm polling. 然后转到“构建触发器”选项卡,为GITScm轮询选择GitHub挂钩触发器。

Don't forget to add webhook <YOUR-JENKINS-URL>/github-webhook/ to your Github project and select sending push events as json. 不要忘记将webhook <YOUR-JENKINS-URL>/github-webhook/到您的Github项目中,并选择发送推送事件作为json。

With this way, you can create a build whenever a push made to a specific branch. 通过这种方式,您可以在每次推送到特定分支时创建构建。 With pooling, it will pull the repository with given time intervals, which is way more costly. 有了池,它将以给定的时间间隔拉动存储库,这会增加成本。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM