在Jenkins作业中访问BitBucket Webhook的有效负载 [英] Accessing the BitBucket webhook's payload in Jenkins jobs

查看:85
本文介绍了在Jenkins作业中访问BitBucket Webhook的有效负载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当推送事件发生时,我在Bitbucket上使用webhooks来触发Jenkins的构建,为此,我正在使用Bitbucket插件. 我的Jenkins管道包含多个交叉依赖的任务,例如:

I'm using webhooks on Bitbucket to trigger builds on Jenkins when push event occurs, for this purpose I'm using Bitbucket plugin. My Jenkins pipeline consist of multiple cross depending tasks e.g.:

主管道(触发任务)

    Main pipeline (triggered task)

        1)构建docker映像
        1) build docker images

        2)运行测试

        3)做点事情

      按预期触发生成,但是任务失败,因为它们依赖于我需要提供的特定分支.不幸的是,我不知道如何访问具有我所需全部信息的webhook负载.

      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.

      替代方法是在Jenkins中使用Poll CMS选项,但我更喜欢按需构建而不是定期构建.

      The alternative would be using Poll CMS option in Jenkins but I prefer to build on demand and not periodically.

      推荐答案

      发件人:

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

      他们说:

      从1.1.5版本开始,Bitbucket自动将Bitbucket接收到的有效负载注入到构建中.您可以通过环境变量$ BITBUCKET_PAYLOAD捕获有效负载以对其进行相应处理.

      Since 1.1.5 Bitbucket automatically injects the payload received by Bitbucket into the build. You can catch the payload to process it accordingly through the environmental variable $BITBUCKET_PAYLOAD.

      致谢

      这篇关于在Jenkins作业中访问BitBucket Webhook的有效负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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