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
- Create a new Action by clicking CREATE button
- Enter a name: Create new repo and click CREATE
- 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 - 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 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.
- Click Triggers tab
- Select ISSUE RESOLVED event, in this example we will use the Issue Resolved event to indicate that the user shall be added.
- On JQL Condition. When to execute the event(s) write Project = TESTB and to limit the trigger to the TESTB project
- Click SAVE
- (Optional) Click Test button (no issue key is needed) to and click Send, Then go Log Tab.
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.