I would like to create Jira issue when pull request is created in BitBucket. So I've read in documentation that there is a PullRequestOpenedEvent. In addition, I've read that there is Pre Hooks.
Guys, do you know what should I use to create Jira task in Jira when pull request is created in Jira?
If you could provide some code or links, it would be really helpful. Any help would be greatly appreciated.
Hi @zaharovvv_suek_ru ,
Looking at the links you provided, it looks like you are using the app ScriptRunner for Bitbucket?
If that is the case, then you want to create a Custom Event Handler in ScriptRunner for Bitbucket, that listens for the PullRequestOpenedEvent and then creates a Jira issue via the Jira REST API.
Here is an example script in our documentation which updates a Jira issue when a Pull Request is opened: https://scriptrunner.adaptavist.com/6.0.1/bitbucket/StashEventHandlers.html#_update_all_related_jira_issues_when_pull_request_opened
You should be able to use this script as a base and then edit it to create, rather than update a Jira issue my changing the REST API used.
Kind regards,
Robert Giddings,
Product Manager for ScriptRunner for Bitbucket
@Robert Giddings _Adaptavist_ thank you for your answer!
It was not simple to create an issue from the Bitbucket. I've tried to create an issue, however issue is not created and there is no errors. Could you, please, see this question?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Yeah, you got the right direction, first, you need to catch the event, in your add-on it will be something like that:
```
@EventListener
public void onPullRequestOpened(PullRequestOpenedEvent event) {
```
You don't need pre hooks, you just define a class and use that @EventListener annotation, so your java code receives these events from now on.
It's the first part, the second part is creating a Jira issue. For your add-on Jira is just a remote server with a REST API, so you just need to consume this API and create an issue by making specific HTTP requests.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Egor Kovetskiy thank you for your answer. It was not simple to create an issue from the Bitbucket. I've tried to create an issue, however issue is not created and there is no errors. Could you, please, see this question?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.