简体   繁体   English

每当有新的提交发生时就进行构建,Jenkins + github?

[英]Build whenever a new commit happen , Jenkins + github?

We have a master branch, on which developer creates branches as feature/US-**** and then commit and push the feature branch to git. 我们有一个master分支,开发人员在该分支上将其创建为feature / US-****,然后提交并将其推入git。

There can be multiple feature branches for one master branch. 一个主分支可以有多个功能分支。

Now this is where I need to trigger the build. 现在这是我需要触发构建的地方。 (On creation of new feature branch and on every commit/push). (在创建新功能分支以及每次提交/推送时)。

I have a setup where I am polling my SCM for every H/5 * * * * and I have kept, 我有一个设置,在该设置中,我会针对每个H/5 * * * *轮询SCM,并且我一直保持着,

Branch Specifier (blank for 'any') = */feature/*
Refspec = +refs/heads/feature/*:refs/remotes/feature/*

But this still print log as : 但这仍然将日志打印为:

Seen branch in repository origin/master.... 

Whereas I need to trigger build on feature branch creation and on every commit on those feature branch. 而我需要在功能分支的创建以及这些功能分支的每次提交上触发构建。 Also it should not pickup those branches which has already been merged with the master? 还不应该提取那些已经与母版合并的分支吗?

Is this setup possible? 这种设置可行吗?

Yes, absolutely possible. 是的,绝对有可能。 The best setup I've personally used is a git webhooks. 我个人使用的最佳设置是git webhooks。 You can specify what events to fire events from in the webhook configuration screen: webhook example config 您可以在webhook配置屏幕中指定触发事件的事件: webhook示例config

You'll need the jenkins github plugin: https://wiki.jenkins.io/display/JENKINS/GitHub+Plugin 您将需要jenkins github插件: https ://wiki.jenkins.io/display/JENKINS/GitHub+Plugin

Then you just point github to your jenkins instance as the webhook endpoint and configure the trigger on your job to be triggered by the hook. 然后,您只需将github指向您的jenkins实例作为webhook端点,然后将作业上的触发器配置为由钩子触发即可。 Example: Jenkins githook configuration 示例: Jenkins githook配置

Bonus note: If you are like me and have a private jenkins instance in aws you'll have to do some fanciness with lambda and api-gateway to get github to hook in correctly. 温馨提示:如果您像我一样,并且在aws中有一个私有的jenkins实例,则必须对lambda和api-gateway进行一些幻想,以使github正确连接。 I used this code to do it: https://github.com/pristineio/lambda-webhook 我用以下代码来做到这一点: https : //github.com/pristineio/lambda-webhook

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

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