简体   繁体   English

Bitbucket webhook触发詹金斯的工作

[英]Bitbucket webhook to trigger Jenkins job

I'm having trouble getting my webhook in bitbucket server to start a Jenkins job. 我无法在bitbucket服务器中获取webhook以启动Jenkins工作。 I've read through the other answered questions on here and can't get it going. 我已经在这里阅读了其他已回答的问题并且无法理解。

Bitbucket setup: Bitbucket设置:

  • No special plugins installed 没有安装特殊插件
  • In repository settings I have a webhook set up 在存储库设置中,我设置了一个webhook
  • URL: http://[my jenkins url]/bitbucket-hook/ (yes I have the trailing slash) URL: http:// [my jenkins url] / bitbucket-hook /(是的,我有尾部斜杠)
  • Repo Push event selected 选择Repo Push事件

Jenkins setup: 詹金斯设置:

  • Bitbucket plugin installed 已安装Bitbucket插件
  • Created new job 创造了新的工作
  • Set SCM to Git and added repo details 将SCM设置为Git并添加了repo详细信息
  • Set branches to build to either ** or refs/heads/rob-jenkins (a branch in git) 将分支设置为**或refs / heads / rob-jenkins(git中的分支)
  • Build when a change is pushed to bitbucket selected 将更改推送到选择的bitbucket时构建

What I do: I make a change to a file in rob-jenkins branch, push and the job is not started in Jenkins. 我的所作所为:我在rob-jenkins分支中对文件进行了更改,推送并且Jenkins中的作业未启动。

What I see: In bitbucket, repo settings, webhooks I can see the webhook fired as soon as the commit is pushed. 我所看到的:在bitbucket,repo设置,webhooks我可以看到webhook在提交被提示后立即触发。 It has a 200 http status code, response body is empty. 它有一个200 http状态代码,响应体是空的。

In Jenkins I've set up a logger for 在詹金斯,我已经设置了一个记录器

com.cloudbees.jenkins.plugins.BitbucketHookReceiver
com.cloudbees.jenkins.plugins.BitbucketJobProbe
com.cloudbees.jenkins.plugins.BitbucketPayloadProcessor
com.cloudbees.jenkins.plugins.BitBucketTrigger

And when I look at those logs I can see only 1 entry from com.cloudbees.jenkins.plugins.BitbucketHookReceiver 当我查看这些日志时,我只能看到com.cloudbees.jenkins.plugins.BitbucketHookReceiver中的一个条目

Received commit hook notification : {"eventKey":"repo:refs_changed","date":"2018-05-22T12:18:11+1000","actor":{"name":"xxxxxx","emailAddress":"xxxxxx@xxxxxx.com","id":53,"displayName":"xxxxxx","active":true,"slug":"xxxxxxx","type":"NORMAL"},"repository":{"slug":"xxxxx","id":1,"name":"xxxxx","scmId":"git","state":"AVAILABLE","statusMessage":"Available","forkable":true,"project":{"key":"SS","id":2,"name":"xxxxx","description":"xxxxxx","public":false,"type":"NORMAL"},"public":false},"changes":[{"ref":{"id":"refs/heads/rob-jenkins","displayId":"rob-jenkins","type":"BRANCH"},"refId":"refs/heads/rob-jenkins","fromHash":"1d9ad42fa404c893853094b0072e5b839f787589","toHash":"9bf7dc873f355259e4338ee80afbd246ecbb48a9","type":"UPDATE"}]}

There are no other entries in the log. 日志中没有其他条目。

In the job itself, the BitBucket Hook Log screen just says "Polling has not run yet." 在作业本身,BitBucket Hook Log屏幕只是说“轮询尚未运行”。

No idea why it isn't triggering the Jenkins job... what am I missing? 不知道为什么它不会触发詹金斯的工作......我错过了什么?

  • I've tried setting the Poll SCM manually and that didn't make a difference. 我已经尝试手动设置Poll SCM,这没有什么区别。
  • I've done a manual build and it works fine 我做了一个手动构建,它工作正常

as commented by @tomas-bjerre the resolution was to use a different plugin 正如@ tomas-bjerre评论的那样,决议是使用不同的插件

I would recommend using thie plugin instead: github.com/jenkinsci/generic-webhook-trigger-plugin – Tomas Bjerre yesterday 我建议使用这个插件:github.com/jenkinsci/generic-webhook-trigger-plugin - 昨天Tomas Bjerre

No plugin needed. 不需要插件。 Just add a post-recieve hook under your repo in Bitbucket. 只需在Bitbucket的repo下添加一个post-recieve hook。 On Jenkins, under Build Triggers, Trigger builds remotely (eg, from scripts) Trigger builds remotely (eg, from scripts) and specify an Authentication Token. 在Jenkins上,在Build Triggers下,触发器远程构建(例如,从脚本)触发器远程构建(例如,从脚本)并指定认证令牌。 A bash or python script can be used for the hook. bash或python脚本可用于钩子。 Anytime a git push is run (not just a commit), you trigger a build! 无论何时运行git push(而不仅仅是提交),都会触发构建!

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

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