Bitbucket云Webhook不触发Jenkins构建:无分支信息 [英] Bitbucket cloud webhook Does not trigger Jenkins Build: No branch information

查看:334
本文介绍了Bitbucket云Webhook不触发Jenkins构建:无分支信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Bitbucket云与Jenkins集成.我在Jenkins中安装了Bitbucket插件.我已使用网址http://<jenkins_url>/bitbucket-hook/

I am trying to integrate Bitbucket cloud with Jenkins. I have Bitbucket plugin installed in Jenkins. I have configured the webhook in bitbucket cloud for the repository with url http://<jenkins_url>/bitbucket-hook/

我设置了詹金斯的工作(我尝试了管道和多分支管道).在管道中,我选择了将更改推送到BitBucket时进行构建",在管道中,我具有从bitbucket中获取和构建的阶段.我已指定从分支开发中获取.

I set up Jenkins job (I tried both pipeline and multibranch pipeline). In the Pipeline I have selected "Build when a change is pushed to BitBucket" and In the pipeline I have stages to fetch from bitbucket and build. I have specified to get from branch develop.

情况1::设置完成后,我将一些代码推送到了我的存储库(分支开发).我希望管道被触发(因为我有一个Webhook设置),所以什么也没发生.
我手动触发了构建.它建立了项目.现在,如果我将某些内容推送到存储库,则将触发构建.这里的问题是,为什么它没有第一次触发并且仅在手动构建后才起作用.

case 1: After I set this up I pushed some code to my repository(branch develop). I expected the pipeline to be triggered(since I have a webhook setup) nothing happens.
I triggered the build manually. It builds the project. Now if I push something to the repository, the build is getting triggered. Question here is Why didn't it triggered the first time and works only after a manual build.

情况2:我设置了另一个管道.就像以前一样.但以分支机构为主.我尝试遵循相同的步骤(先手动触发).现在,当我推些东西要掌握时.什么也没有发生(即使在手动构建之后).

case 2: I setup another pipeline. Exactly as the one before. But with branch as master. I tried to follow the same step(triggered manually first). Now when i pushed something to master. Nothing happens(even after manual build).

当我分析詹金斯日志时.我发现,一旦推送某些内容,bitbucket云便会发出通知.但是发送的json没有分支信息.可能是因为当有多个管道与同一个存储库进行通信时,Jenkins无法决定触发哪个管道的原因.我的假设正确吗?这是Bitbucket云中的错误

When I analysed the jenkins log. I see that there is a notification from bitbucket cloud as soon as something is pushed. But the json which is sent doesn't has branch information. May be that is the reason Jenkins is not able to decide which pipeline to trigger when there are multiple pipelines talking to same repository. Is my assumption correct? Is it a bug in Bitbucket cloud

从位桶云中接收到的json看起来像这样

The json recieved from bitbucket cloud looks like this

{
   "scm": "git",
   "website": null,
   "name": "myproject-api",
   "links": {
      "self": {
         "href": "https://api.bitbucket.org/2.0/repositories/my-team/myproject-api"
      },
      "html": {
         "href": "https://bitbucket.org/my-team/myproject-api"
      },
      "avatar": {
         "href": "https://bytebucket.org/ravatar/%7Bb07e7384-c622-44b1-8c5f-96104d36cfae%7D?ts=java"
      }
   },
   "project": {
      "key": "PB",
      "type": "project",
      "uuid": "{d9c0caa2-7d43-4a0e-8459-2c7c8c2bd287}",
      "links": {
         "self": {
            "href": "https://api.bitbucket.org/2.0/teams/my-team/projects/PB"
         },
         "html": {
            "href": "https://bitbucket.org/account/user/my-team/projects/PB"
         },
         "avatar": {
            "href": "https://bitbucket.org/account/user/my-team/projects/PB/avatar/32"
         }
      },
      "name": "MyProject Backend"
   },
   "full_name": "my-team/myproject-api",
   "owner": {
      "username": "my-team",
      "display_name": "my-team",
      "type": "team",
      "uuid": "{848f7612-ffbc-4dfb-8f67-ade4b604761c}",
      "links": {
         "self": {
            "href": "https://api.bitbucket.org/2.0/teams/%7B848f7612-ffbc-4dfb-8f67-ade4b604761c%7D"
         },
         "html": {
            "href": "https://bitbucket.org/%7B848f7612-ffbc-4dfb-8f67-ade4b604761c%7D/"
         },
         "avatar": {
            "href": "https://bitbucket.org/account/my-team/avatar/"
         }
      }
   },
   "type": "repository",
   "is_private": true,
   "uuid": "{b07e7384-c622-44b1-8c5f-96104d36cfae}"
}

任何人都不知道如何成功地使Webhooks与Bitbucket Cloud和Jenkins一起工作. SO上与此相关的大多数问题都在谈论Bitbucket服务器,而不是Bitbucket云.

Does anyone have any idea how to successfully get webhooks working with bitbucket cloud and Jenkins. Most of the questions on SO regarding this talks about Bitbucket server and not Bitbucket cloud.

推荐答案

我通过执行以下步骤解决了类似的问题:

I had similar issues solved by doing following steps:

  1. 卸载旧的"Bitbucket"插件
  2. 删除了设置为的bitbucket的webhook:
    • http://< Jenkins URL>/bitbucket-hook/
  1. Uninstall old 'Bitbucket' plugin
  2. Removed webhook at bitbucket that was set as:
    • http://<Jenkins URL>/bitbucket-hook/
  • http://< Jenkins URL>/bitbucket-scmsource-hook/notify/

干杯!

这篇关于Bitbucket云Webhook不触发Jenkins构建:无分支信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆