如何在合并的Bitbucket Pull请求上触发Jenkins构建 [英] How to trigger jenkins build upon bitbucket pull request merged
问题描述
我查看了所有其他相关的问题和答案,但没有发现任何可靠的内容,因此,我打开一个新问题来寻求您的友好帮助,我整天都在努力,尽我所能得到将不胜感激.
I looked at all other related questions and answers, didn't find anything solid, hence I'm opening a new question to look for your kind help, I've been working on this the whole day, any help I can get would be highly appreciated.
这是我的环境:
- 安装了git和bitbucket插件的自托管jenkins服务器(Jenkins版本1.651.3).
- https://bitbucket.org (我没有自托管的Bitbucket服务器)
- self-hosted jenkins server (Jenkins ver. 1.651.3) with git and bitbucket plugin installed.
- https://bitbucket.org (I do not have a self-hosted bitbucket server)
我想做的事情:在拉取请求从要素分支合并到主分支后触发jenkins构建.
我尝试过的不同设置组合:
Different setting combinations which I had tried:
-
- jenkins:在将更改推送到BitBucket时进行构建"已选中.
- bitbucket:Web挂钩触发:存储库推送"已选中.
- jenkins: 'Build when a change is pushed to BitBucket' checked.
- bitbucket: web hooks trigger: 'Repository push' checked.
结果:在提交到master分支后成功触发了构建,但这不是我想要的,但是至少我知道我的jenkins服务器与bitbucket之间的通信很好.
Result: build was triggered successfully upon commit to master branch, but that's not what I want, but at least I know the communication between my jenkins server and bitbucket is fine.
-
- jenkins:在将更改推送到BitBucket时进行构建"已选中.
- bitbucket:Web挂钩触发:选中存储库推送",并选中提取请求-合并".
- jenkins: 'Build when a change is pushed to BitBucket' checked.
- bitbucket: web hooks trigger: 'Repository push' checked, and Pull Request - 'Merged' checked.
结果:詹金斯不响应合并请求的合并请求.我认为这是可行的,因为我在Web挂钩触发器设置中选中了Pull Requst-"Merged",并且确实看到请求是由bitbucket发送到我的jenkins服务器的,并且从我的jenkins服务器获取了200个状态代码,但仍然没有任何反应.
Result: jenkins does not respond to the pull request merged action. I assumed it would work since I had the Pull Requst - 'Merged' checked in the web hooks trigger setting, and I did see the request was sent by bitbucket to my jenkins server, and it got 200 status code back from my jenkins server, but still, nothing happens.
-
- jenkins:已选中将更改推送到BitBucket时生成".除此之外,我还安装了另一个名为bitbucket-pullrequest-builder-plugin的插件,并根据说明进行了配置.
- bitbucket:Web挂钩触发:选中存储库推送",并选中提取请求-合并".
- jenkins: 'Build when a change is pushed to BitBucket' checked. And besides that, I installed another plugin called bitbucket-pullrequest-builder-plugin, and configured it according to the instruction.
- bitbucket: web hooks trigger: 'Repository push' checked, and Pull Request - 'Merged' checked.
结果:借助bitbucket-pullrequest-builder-plugin,确实在创建请求请求时触发了构建.但是jenkins服务器会不断轮询bitbucket存储库,而我没有找到一种方法来阻止这种情况,没有办法仅在合并后就不会触发构建...
Result: with the help of bitbucket-pullrequest-builder-plugin, the build was indeed triggered upon pull request created. But the jenkins server polls the bitbucket repository constantly, and I didn't find a way to stop that, no way to trigger build ONLY upon merge neither...
我听说有人说您需要在bitbucket服务器上安装一个后挂接插件才能执行我想做的事情,但是事情是我不托管bitbucket ...
I heard there's people says that you'll need to install a post-hook plugin on the bitbucket server in order to do what I want to do, but the thing is I dont host the bitbucket...
推荐答案
在配置GIT-推送,提交...等挂钩时,请务必检查JENKINS git选择,并将BRANCH设置为检查(**指定所有分支),最重要的是,
When you configure GIT - push, commit... etc hooks, be sure to check the JENKINS git selection, and set the BRANCH to check for (** specifies all branches) and most importantly,
使用localtunnel.me或类似工具将您的JENKINS设置为在线,否则它将无法正常工作.
USE localtunnel.me or similar to set your JENKINS online or it won't work.
这篇关于如何在合并的Bitbucket Pull请求上触发Jenkins构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!