Sign inSign up

computronix/bitbucket-pipe-jiraissue

By computronix

•Updated about 4 years ago

Bitbucket Pipelines Pipe: Create and Update Jira Issue

Image
0

509

computronix/bitbucket-pipe-jiraissue repository overview

⁠Bitbucket Pipelines Pipe: Create and Update Jira Issue

This pipe allows you to automatically create and update JIRA issues if a build step fails.

⁠YAML Definition

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>'

⁠Variables

VariableUsage
bitbucket_api_oauthconsumer_keyOauth consumer key for the workspace
bitbucket_api_oauthconsumer_secretOauth consumer secret for the workspace
jira_api_urlURL for Jira API
jira_projectCode for the Jira project issues should be assigned against (e.g. PC3)
jira_bearer_tokenBearer token that has read/write access to issues on the desired Jira project

⁠Examples

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.

Tag summary

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