本文介绍了触发GitHub PUSH上的Jenkins作业到特定分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试基于GitHub PUSH触发某个分支的作业.

I'm trying to trigger a job based on a GitHub PUSH to a certain branch.

我在没有计划的情况下将Webhook设置为JENKINS_URL/git/notifyCommit?url=REPO_URLPoll SCM.

I set up a webhook to JENKINS_URL/git/notifyCommit?url=REPO_URL and Poll SCM without schedule.

每个push都会触发该作业,但是我无法过滤出分支-我希望仅在有主键推动时才会发生.

The job is being triggered for every push but I cannot filter out the branch - I'd like it to only happen when there's a push to master.

推荐答案

我最初是在寻找一些插件,但没有找到任何可满足您要求的插件.

I initially looked for some plugins but I didn't find anything to achieve as your requirements.

最初,我曾经创建一个单独的作业并在那里检测分支,而不是仅在下游构建另一个作业.

Initially I used to create a separate job and detect the branch there and than only build another jobs as downstream.

这就是我所做并成功实现的目标.该功能已经在Jenkins中提供,我们不必为此安装任何插件.

This is what I have done and achieved it successfully. The feature is already available in Jenkins and we don't have to install any plugin for it.

我认为,波纹管将使所有事情变得清晰.

I think, the image bellow will make every thing clear.

因此,如果我们只想在将更改推送或合并到TEST分支时才触发作业,则可以执行此操作.

So if we want to trigger the job only when the changes is pushed or merged to TEST branch we do this.

有关完整信息,请阅读我的博客

For full information read my blog on it

这篇关于触发GitHub PUSH上的Jenkins作业到特定分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 21:05