How to create Bitbucket repository during a workflow transition using Run CLI Actions in Jira

This article explains how to create a Bitbucket repository during a workflow transition using the Run CLI Actions in Jira app.

Instructions

Use createRepository action to create a Bitbucket repository. Add this CLI action in the relevant Jira workflow where the action is to be executed

  1. Log in as a Jira administrator.
  2. Navigate to > Issues and click Custom fields.
  3. Click Add Custom field to create two custom fields of type, Text field, to add the Bitbucket repository and project to the specific screens. 
  4. Click Edit to modify the concerned workflow under the Workflows tab.
  5. Select the transition to be added or edit the post function, and then select the Post Functions option.
  6. Select CLI action from the available options and click Add.

  7. Add the createRepository Bitbucket CLI action under Action field as shown in the screenshot.

     -a createRepository --server http://example.com/ --user xxxx --password xxxx --project "%original_customfield_xxxx%" --repository "%original_customfield_xxxxx%"
    Here, replace the server, user, and password parameters, and enter the custom field substitution variables for the project and repository parameters.
  8. Click Add and Publish the workflow.
  9. Create an issue, and enter the value of the Bitbucket repository and project name in the custom field.

  10. Perform the transition on the issue to which post-function has been added. It creates the repository in Bitbucket if the repository does not already exist.

The parameters used with the action are:

  • --server value refers to the URL of the Bitbucket instance.
  • --user value refers to the Bitbucket username.
  • --password value refers to the Bitbucket password.
  • --project value refers to the Bitbucket project.
  • --repository value refers to the repository name.