Bitbucket Pipelines Pipe: Create and Update Jira Issue
509
This pipe allows you to automatically create and update JIRA issues if a build step fails.
Add the following snippet to the script section of your bitbucket-pipelines.yml file:
- pipe: docker://computronix/bitbucket-pipe-jiraissue:0.1.0
variables:
bitbucket_api_oauthconsumer_key: '<string>'
bitbucket_api_oauthconsumer_secret: '<string>'
jira_api_url: '<string>'
jira_project: '<string>'
jira_bearer_token: '<string>'
| Variable | Usage |
|---|---|
| bitbucket_api_oauthconsumer_key | Oauth consumer key for the workspace |
| bitbucket_api_oauthconsumer_secret | Oauth consumer secret for the workspace |
| jira_api_url | URL for Jira API |
| jira_project | Code for the Jira project issues should be assigned against (e.g. PC3) |
| jira_bearer_token | Bearer token that has read/write access to issues on the desired Jira project |
To get the most use out of this pipe, it is recommended that it is added to pipeline builds as an after-script step run after every step if there was a failure in that step. In example of how that might look is provided below, with the pipe being saved as a YAML anchor:
definitions:
# Creating the YAML anchor
ticket-on-error: &ticket-on-error
# Check the BitBucket exit code to see if the step failed before creating a ticket.
# Only proceed if the step failed.
- if [ $BITBUCKET_EXIT_CODE -ne 1 ]; then exit 0; fi
- pipe: docker://computronix/bitbucket-pipe-jiraissue:0.1.0
variables:
bitbucket_api_oauthconsumer_key: $BITBUCKET_OAUTH_CONSUMER_KEY
bitbucket_api_oauthconsumer_secret: $BITBUCKET_OAUTH_CONSUMER_SECRET
jira_api_url: $JIRA_API_URL
jira_bearer_token: $JIRA_API_TOKEN
jira_project: "PC3"
...
pipelines:
default:
- step:
name: Step 1
script:
- do something
# Call the anchor in an after-script step
after-script: *ticket-on-error
- step:
name: Step 2
script:
- do something else
after-script: *ticket-on-error
...
Note that the script within the pipe also has logic to check if the step which is calling the pipe has failed, and will already only run if the step has failed. However, relying on this means the after-script step will still build the docker container to run the pipe every step, which can result in a lot of wasted build time.
Content type
Image
Digest
sha256:4b84445db…
Size
5.7 MB
Last updated
about 4 years ago
docker pull computronix/bitbucket-pipe-jiraissue:0.4.2