Create a repository when issue is approved

On this tutorial, we will create a Bitbucket server repository when an issue is resolved in our TESTB project.

In our JIRA instance, there is a text custom field with id 10002 that will be used as input for the project key and another for the name with id 10003.

Steps

  1. Create a new Action by clicking CREATE button
  2. Enter a name: Create new repo and click CREATE
  3. Select Method: POST and URL: <your_bitbucket_base_url>/rest/api/1.0/projects/{{issue.customfield_10002}}/repo
    From the Atlassian REST API we can read that to add a repo to a project we need to call POST/rest/api/1.0/projects/{projectKey}/repos
  4. Select Authentication method: Basic Auth, specify a user that must have PROJECT_ADMIN permission for the context project to call this resource.
    Add request headers, key: Content-Type with value application/json
  5. On the Body section add the following

    {
        "name": "{{issue.customfield_10003}}",
        "scmId": "git",
        "forkable": false
    }

    Here we use the mustache syntax to grab the custom field data.

  6. Click Triggers tab
  7. Select ISSUE RESOLVED event, in this example we will use the Issue Resolved event to indicate that the user shall be added. 
  8. On JQL Condition. When to execute the event(s) write Project = TESTB and to limit the trigger to the TESTB project
  9. Click SAVE
  10. (Optional) Click Test button (no issue key is needed) to and click Send, Then go 3 - View Execution Log.

Result will have a response like the one below:

Optional steps to inform the reporter about the repo benig added is to create a chained action that comments the issue.