Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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 
    Status
    colourBlue
    titleCreate
     button
  2. Enter a name: Create new repo and click 
    Status
    colourBlue
    titleCreate
  3. Select Method:
    Status
    colourYellow
    titlePOST
     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

    Code Block
    {
        "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 
    Status
    colourGreen
    titleIssue 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 
    Status
    colourBlue
    titleSAVE
  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.