What is the best way to access the jira rest api, from within the Bamboo task plugin? I have an application link setup, but when I try to use something like:
input = new URL(url + "/rest/api/latest/search/?jql=" + jql).openStream(); reader = new InputStreamReader(input, "UTF-8"); data = new Gson().fromJson(reader, JiraData.class);
There's authentication issues. What's the best method to handle something like this? I'm trying to create an issue through the rest api. I have been able to create an issue through the rest api using just a regular shell script, with basic authentication, but in this case, i'm trying to use the application link authorization in Bamboo.
Community moderators have prevented the ability to post new answers.
Hey Casey,
Maybe you could use http://docs.atlassian.com/bamboo/4.3/com/atlassian/bamboo/jira/rest/JiraRestService.html to do that? You would need to inject the JiraRestService into your task somehow, and pass there ApplicationLink to your JIRA as well. Then you could execute something like:
JiraRestResponse response = jiraRestService.doRestCallViaApplink(applicationLink, "rest/api/latest/search/?jql="+jql, GET, null); data = new Gson().fromJson(wrapIntoReader(response.body), JiraData.class);
I think to retrieve the list of app-linked JIRAs you can use http://docs.atlassian.com/bamboo/4.3/com/atlassian/bamboo/applinks/JiraApplinksService.html
Is that helpful?
According to the pom.xml, it's 4.2.2. I noticed the api link you sent is for 4.3. I tried updating the pom, but it can't find the updated version in the sdk repo.
Here's the relevant portion of my pom.xml:
...
<properties>
<bamboo.version>3.2.2</bamboo.version>
<bamboo.data.version>3.2.2</bamboo.data.version>
<amps.version>4.1.2</amps.version>
</properties>
...
<dependency>
<groupId>com.atlassian.bamboo</groupId>
<artifactId>atlassian-bamboo-web</artifactId>
<version>${bamboo.version}</version>
<scope>provided</scope>
</dependency>
...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Piotr,
Thank you very much, that info looks to be exactly what I need. However, i'm having a dependency issue. I can't get the JiraRestService import to work. I'm using something like:
import com.atlassian.bamboo.jira.rest.JiraRestService;
But it is unresolved. Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Which Bamboo version are you writing your task plugin against?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In line 2 of your example, where does the wrapIntoReader method come from?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I just answererd my question myself. Looks like I was actually using 3.2.2 Ha, I changed it to 4.2.2, and did atlas-mvn eclipse:eclipse, and now the dependency is resolved. Thanks for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
...........
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must write it. I assume that you want to convert the response from JIRA into some JiraData class (I don't know what that is). So probably you will need to convert+adjust JiraRestReponse.body (which is String I presume) into some StreamInputReader, or Json object - dunno. But I'm pretty sure that you will manage to figure that out. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok that makes sense. I'm now having issues running the plugin in Bamboo. In eclipse, the import shows as valid, there arn't any errors. But when I try to install plugin into bamboo, I get an error about a unique bean not being found for the JiraRestService. I tried adding a component-import to my atlassian-plugin.xml, but that did not resolve the issue. I have the following in my atlassian xml file:
<component-import key="jira-rest-service" name="Jira Rest Service" interface="com.atlassian.bamboo.jira.rest.JiraRestService">
<description>Jira rest service stuff</description>
</component-import>
With the above in my xml, it still doesn't work. Instead it gives me the error:
[OsgiPlugin] Never resolved service '&jira-rest-service' for plugin 'com.build.bamboo.plugins.VeracodePlugin' with filter (objectClass=com.atlassian.bamboo.jira.rest.JiraRestService)
Any ideas why this wouldn't work?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Which "pluginsVersion" are you using? 2? (in atlassian-plugin.xml) If so, can you temporarily switch to 1? (note: that way you would have to restart Bamboo to install that plugin).
I'm thinking that maybe we didn't expose yet the JiraRestService to the plugins of version 2...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried changing the version to 1, and then did an "atlas-clean" followed by atlas-run, and ended up with several stack traces, resulting in Bamboo not being able to start. Switching back the verison, and running the atlas-clean + atlas-run, enabled Bamboo to run again.
I'm wondering how the Jira Plugin that ships with Bamboo handles this. Any idea where the source is for that?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think the bamboo-to-jira integration code is shipped together with Bamboo source. Do you have access to it? AFAK it comes with the more expensive licenses...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I am new in Bamboo plugin dev and I can not figure our how I can get the "applicationLink".
How do we use the JiraApplinksService ?
Best regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yann,
What are you trying to achieve?
Actually I think it could be a better idea to raise a new question here on answers.atlassian.com, than trying to continue discussion here via comments... wouldn't it?
cheers,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No problem. Just remember to mark it with bamboo-plugin-development tag :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I have acces. I will take a look. Thank you for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
CreateNewJiraIssueAction.java might be a good starting point for you then.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.