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
buttonStatus colour Blue title Create - Enter a name: Create new repo and click
Status colour Blue title Create - Select Method:
and URL: <your_bitbucket_base_url>/rest/api/1.0/projects/{{issue.customfield_10002}}/repoStatus colour Yellow title POST
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
Code Block { "name": "{{issue.customfield_10003}}", "scmId": "git", "forkable": false }
Here we use the mustache syntax to grab the custom field data.
- Click Triggers tab
- Select
event, in this example we will use the Issue Resolved event to indicate that the user shall be added.Status colour Green title Issue RESOLVED - On JQL Condition. When to execute the event(s) write Project = TESTB and to limit the trigger to the TESTB project
- Click
Status colour Blue title SAVE - (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.