Hi,
We are using JIRA Software, Bitbucket Server, Bamboo Server. I'd like to trigger a specific bamboo build after a JIRA workflow transition. To do these I want to gather additional information from the issue, like last successful build, assignee and.. Bitbucket branch.
I already tried access these data via script-runner as mentioned here https://gist.github.com/jechlin/99f0853f579c7e4edb34 but realized that this solution only applicable if we are using Bitbucket cloud or Github. It will not work if we work with Bitbucket Server
In general, I have a two ideas of how I can access development data(such as branch, pull-request, e.t.c):
The question is, where I can find an API of "jira-software-plugin" or can someone helps me with accessing data via application link?
Thank you,
Best,
Community moderators have prevented the ability to post new answers.
I, finally, found a solution of my problem!
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.plugin.devstatus.api.DevStatusSummaryService import com.atlassian.jira.plugin.devstatus.rest.DetailBean import com.atlassian.jira.user.ApplicationUser import com.onresolve.scriptrunner.runner.customisers.WithPlugin @WithPlugin("com.atlassian.jira.plugins.jira-development-integration-plugin") DevStatusSummaryService devStatusSummaryService = ComponentAccessor.getOSGiComponentInstanceOfType(DevStatusSummaryService.class) ApplicationUser currentUser = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser() DetailBean pullRequestData = devStatusSummaryService.getDetailData(issue.id, "stash", "pullrequest", currentUser).get()
pullRequestData object will contain information about pull-requests and branches of the issue. You could use the same approach for accessing bamboo builds data as well.
Thank you all,
Hi Mikhail,
Glad you got it working. I came across that plugin while investigating this and it seems that you can't access the source code for it. It looks like its one of those you need to unzip the JAR for and decompile to see whats going on.
Nice use of @WithPlugin.
Thanks,
Adam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Mikhail for sharing this nice script.
I am using SVN sub-version and would like to get the branches of the issue(i,e to which are all branches JIRA issue Fix is submitted) using pullRequestData object.
DetailBean pullRequestData = devStatusSummaryService.getDetailData(issue.id, "subversion", "pullrequest", user).get()
can you please suggest how to get the 'branches of the issue'(s) details and compare with one custom field to match with. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I added the script as part of project workflow scripted post-function and got the below output after adding the below line::
DetailBean pullRequestData = devStatusSummaryService.getDetailData(issue.id, "subversion", "pullrequest", user).get()
log.debug(pullRequestData)
2016-12-13 16:44:44,497 DEBUG [workflow.ScriptWorkflowFunction]: com.atlassian.jira.plugin.devstatus.rest.DetailBean@31731dd9[detail=[],errors=[],configErrors=<null>]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your best off tagging your question with com.onresolve.jira.groovy.groovyrunner to get a faster response. Not all of us follow the tags you mentioned or the tags in the questions you linked to.
It sounds like what you want to achieve can be done with a scripted post-function in JIRA. You will then need to call the bamboo REST API via an application link between JIRA and Bamboo to trigger a build. You can find examples here of interacting with other Atlassian applications.
The Bamboo REST API is documented here and the Bitbucket REST API is here.
Its just a case of putting it all together but hopefully this will give you an idea of how to approach this problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Adam, thank you for the response.
Yes, I used scripted post function. Yes, I used application link to communicate with Bamboo. And there are no problems at this point.
The problem is on the issue "parameters", precisely pull-request, branch name, and changeset that available in the development panel(Jira Software). As I mentioned in the question, I see a few ways how to do this, but I don't have enough expertise to find a correct way
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
DevStatusSummaryService devStatusSummaryService = ComponentAccessor.getOSGiComponentInstanceOfType(DevStatusSummaryService.class)
I tried this script but devStatusSummaryService is null. I checked that plugin com.atlassian.jira.plugins.jira-development-integration-plugin is installed and all its modules are enabled.
What else can be done?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've found another way to get instance of DevStatusSummaryService:
def ccm = ComponentAccessor.getComponentClassManager()
def service = ccm.newInstance("com.atlassian.jira.plugin.devstatus.impl.DefaultDevStatusSummaryService")
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issue = ComponentAccessor.getIssueManager().getIssueObject("TEST-2")
def details = service.getDetailData(issue.id, "stash", "pullrequest", currentUser).right().get().getDetail()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
"dvcsPullRequestService.getPullRequests(["MY_JIRA_ISSUE_ID"])" returns an empty result for my issue linked with Bitbucket server :(
As I understand, dvcs plugin is responsible for connections with Bitbucket cloud and github only.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you sure it doesn't work for BB server? I think it does.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Another question with this topic: https://answers.atlassian.com/questions/9390795
Related to Github and Bitbucket Cloud integration. Doesn't helps me
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The similar question was found here https://answers.atlassian.com/questions/39785152 and it still without answer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.