Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Raise a Jira when a pull request is created

Chris Shepherd
Contributor
April 2, 2024

Hi folks,

We have a requirement that whenever a pull request is created for a specific branch (production), a Jira issue is created.  Is this possible?  Would we need a plugin like scriptrunner?

Ideally, we would also only be able to merge the PR if the Jira issue is in a specific status.  Is that possible too?

thanks in advance for any pointers.

 

2 answers

3 votes
Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 2, 2024

whenever a pull request is created for a specific branch (production), a Jira issue is created

This part of the problem could be solved if you could call the incoming webhook Jira automation trigger every time when a PR is created. That way you could use the automation rule to test if the branch is a "production"  branch and create the issue if it is. The question is what is the best way to send a webhook call from Bitbucket after a PR creation? You could surely develop a little custom app for that, but if you aren't a developer it could be cumbersome.

This is where ScriptRunner could help, but then you could even develop the "check branch" and "create issue through the Jira REST API" steps in the ScriptRunner executed Groovy script.

Ideally, we would also only be able to merge the PR if the Jira issue is in a specific status.

This part of the problem can be elegantly solved with the Better Commit Policy for Bitbucket app. See the verifying pull requests section in the product guide.

rejected-pull-request.png

Hi @Chris Shepherd,

 

Yes, ScriptRunner for Bitbucket has some built-in features that will help you check against a Jira instance. Having set an application link between your bitbucket and jira, you can:


- Use a Custom Listener , triggered by the 'PullRequestOpenedEvent' to call the jira api and create a new issue, if it doesn't exist (this will need some scripting)
- Or even better you can Require a valid jira exists before a branch or commit is pushed, using the Require Commits to be Associated with a Valid Jira Issue Pre-Hook
- You can block the Merge until a jira ticket is in a certain status by using the 'Require That a Pull Request is Associated with a Valid Jira Issue' Merge-Check by modifying the JQL parameter to specify the status(es) you'd like.

 

Hope this helps! Please let us know if you have further questions or if you want to give it a try and need help with the scripting and setup.

Regards,

Yannis

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events