简体   繁体   English

通过推送到Bitbucket存储库触发本地Jenkins构建

[英]Trigger local Jenkins build with a push to a Bitbucket repository

So I currently have Jenkins setup on a Mac Mini that is connected to my local network. 因此,我目前在连接到本地网络的Mac Mini上安装了Jenkins。 What I would like to do is have Jenkins execute a build when a push is made to my remote Git repository on Bitbucket. 我想做的是,当我对Bitbucket上的远程Git存储库进行推送时,让Jenkins执行构建。 Based on the research that I have done so far, there are people who use Bitbucket POST hook to notify Jenkins when a push is made to the repository. 根据我到目前为止所做的研究,有些人使用Bitbucket POST挂钩在对存储库进行推送时通知Jenkins。 However, this method seems to work if Jenkins is hosted on a remote server. 但是,如果Jenkins托管在远程服务器上,则此方法似乎可行。 Is there a way to trigger a local Jenkins build from a remote Git repository? 有没有办法从远程Git存储库触发本地Jenkins构建? Perhaps there is a specific plugin that I should install? 也许应该安装一个特定的插件?

If you don't want to expose your Jenkins machine to the world, you can instead have it poll your Git repository looking for changes: 如果您不想将您的Jenkins机器公开,可以让它轮询Git存储库以查找更改:

Builds by source changes 通过源更改构建

You can have Jenkins poll your Revision Control System for changes. 您可以让Jenkins轮询版本控制系统以进行更改。 You can specify how often Jenkins polls your revision control system using the same syntax as crontab on Unix/Linux. 您可以使用与Unix / Linux上的crontab相同的语法,指定Jenkins多久轮询一次修订控制系统。 However, if your polling period is shorter than it takes to poll your revision control system, you may end up with multiple builds for each change. 但是,如果您的轮询时间短于轮询版本控制系统所花费的时间,则每次更改可能最终都有多个版本。 You should either adjust your polling period to be longer than the amount of time it takes to poll your revision control system, or use a post-commit trigger. 您应该将轮询周期调整为比轮询版本控制系统所花费的时间更长,或者使用提交后触发器。 You can examine the Polling Log for each build to see how long it took to poll your system. 您可以检查每个构建的轮询日志 ,以了解轮询系统花费了多长时间。

Alternatively, instead of polling on a fixed interval, you can use a URL trigger (described above), but with /polling instead of /build at the end of the URL. 或者,您可以使用URL触发器(如上所述),而不是按固定的时间间隔进行轮询,但是可以使用/polling代替URL末尾的/build This makes Jenkins poll the SCM for changes rather than building immediately. 这使得Jenkins轮询SCM进行更改,而不是立即构建。 This prevents Jenkins from running a build with no relevant changes for commits affecting modules or branches that are unrelated to the job. 这可以防止Jenkins在不影响相关模块或分支与工作无关的提交的情况下进行不带任何更改的构建。 When using /polling the job must be configured for polling, but the schedule can be empty. 使用/polling ,必须配置作业以进行轮询,但是计划可以为空。

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

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