简体   繁体   English

在Jenkins工作中访问BitBucket webhook的有效负载

[英]Accessing the BitBucket webhook's payload in Jenkins jobs

I'm using webhooks on Bitbucket to trigger builds on Jenkins when push event occurs, for this purpose I'm using Bitbucket plugin. 我正在使用Bitbucket上的webhooks在推送事件发生时触发Jenkins上的构建,为此我正在使用Bitbucket插件。 My Jenkins pipeline consist of multiple cross depending tasks eg: 我的Jenkins管道包含多个交叉依赖任务,例如:

Main pipeline (triggered task) 主要管道(触发任务)

      1) build docker images 1)构建docker镜像
      2) run tests 2)运行测试
      3) do something 3)做点什么

The build is triggered when expected but tasks are failing because they rely on specific branch that I need to provide. 构建在预期时触发,但任务失败,因为它们依赖于我需要提供的特定分支。 Unfortunately I don't know how to access the webhook's payload that have all the information I need. 不幸的是,我不知道如何访问webhook的有效载荷,它具有我需要的所有信息。

The alternative would be using Poll CMS option in Jenkins but I prefer to build on demand and not periodically. 替代方案是在Jenkins中使用Poll CMS选项,但我更喜欢按需建立而不是定期建立。

From: 从:

https://wiki.jenkins-ci.org/display/JENKINS/BitBucket+Plugin https://wiki.jenkins-ci.org/display/JENKINS/BitBucket+Plugin

they say: 他们说:

Since 1.1.5 Bitbucket automatically injects the payload received by Bitbucket into the build. 从1.1.5开始,Bitbucket会自动将Bitbucket收到的有效负载注入到构建中。 You can catch the payload to process it accordingly through the environmental variable $BITBUCKET_PAYLOAD. 您可以通过环境变量$ BITBUCKET_PAYLOAD捕获有效负载以相应地处理它。

Regards 问候

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

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