问题
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) build docker images
- 2) run tests
- 3) do something
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.
The alternative would be using Poll CMS option in Jenkins but I prefer to build on demand and not periodically.
回答1:
From:
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. You can catch the payload to process it accordingly through the environmental variable $BITBUCKET_PAYLOAD.
Regards
来源:https://stackoverflow.com/questions/33548769/accessing-the-bitbucket-webhooks-payload-in-jenkins-jobs