Hi,
I am trying to enforce PullRequest policy enforcement using SCriptrunner plugin. I am trying to follow document https://scriptrunner.adaptavist.com/stash/latest/docs/event_handlers/#update-all-related-jira-issues-when-pull-request-opened. this line mentioned in the tutorial doesn't help me. Code breaks at this line.
def keys = jiraIssueService.getIssuesForPullRequest(repository.id, pullRequest.id)*.key
I tried to read documentation, but as per all odcs this is correct format.
Can you please suggest some alternative method or help me in fixing in same method?
Do you have a working app link setup between JIRA and bitbucket? https://confluence.atlassian.com/bitbucketserver/linking-bitbucket-server-with-jira-776640408.html
You should probably be using this example although it looks similar: https://scriptrunner.adaptavist.com/latest/bitbucket/StashEventHandlers.html#_update_all_related_jira_issues_when_pull_request_opened
Yes, I have already replaced imports for Bitbucket. I get this error message , "Pull request creation was canceled.
import com.atlassian.applinks.api.ApplicationLinkResponseHandler import com.atlassian.plugin.PluginAccessor import com.atlassian.sal.api.UrlMode import com.atlassian.sal.api.component.ComponentLocator import com.atlassian.sal.api.net.Request import com.atlassian.sal.api.net.Response import com.atlassian.bitbucket.event.pull.PullRequestOpenedEvent import com.atlassian.bitbucket.integration.jira.JiraIssueService import com.onresolve.scriptrunner.canned.bitbucket.util.BitbucketBaseScript import com.onresolve.scriptrunner.runner.ScriptRunnerImpl import groovy.json.JsonBuilder import groovy.transform.BaseScript @BaseScript BitbucketBaseScript baseScript //PullRequestOpenedEvent event = event def pluginAccessor = ComponentLocator.getComponent(PluginAccessor.class) def jiraIssueService = pluginAccessor.getEnabledPluginModule(ScriptRunnerImpl.PLUGIN_KEY + ":jiraIssueService").getModule() as JiraIssueService //jiraIssueService=com.atlassian.bitbucket.internal.integration.jira.DefaultJiraIssueService@441068c9 def pullRequest = event.getPullRequest() //0 def repository = pullRequest.fromRef.repository //437 assert pullRequest def keys = jiraIssueService.getIssuesForPullRequest(repository.id, pullRequest.id)*.key
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What errors are you seeing in the logs after the script runs?
If your running Bitbucket and not stash, you need to replace "stash" in the imports with "bitbucket", for example:
import com.atlassian.applinks.api.ApplicationLinkResponseHandler import com.atlassian.bitbucket.event.pull.PullRequestOpenedEvent import com.atlassian.bitbucket.integration.jira.JiraIssueService import com.atlassian.plugin.PluginAccessor import com.atlassian.sal.api.UrlMode import com.atlassian.sal.api.component.ComponentLocator import com.atlassian.sal.api.net.Request import com.atlassian.sal.api.net.Response import com.onresolve.scriptrunner.canned.bitbucket.util.StashBaseScript import com.onresolve.scriptrunner.runner.ScriptRunnerImpl import groovy.json.JsonBuilder import groovy.transform.BaseScript
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.