#254 Jira Cloud Support
Feature #254 - Finally JIRA Cloud support!
What
- Add JIRA Cloud OAuth1 support
- Add error message when JIRA cloud application link is not set up correctly
- Add a new JiraApiClient class, because JIRA cloud and JIRA server can use the same requests
- Add a new JiraConfig class to store the jiraUrl, accessToken, consumerKey and privateKey for each connection (shared with JIRA cloud and server)
- Update documentation with a guide on how to set up an application link and how to use Diveni with JIRA cloud
Fix
- Fix accessToken maps can grow indefinitely by removing an accessToken when it's session is deleted
- Fix receiving the tokenIdentifier when creating a session
- Change some endpoints from camelCase to kebab-case
- Replace accessToken with tokenIdentifier as instance variable for each session
- Fix typo and remove unused methods for authenticating with JIRA instances
- Remove unused view
JiraCallbackPage
When creating an issue via Jira Server(v9.11.0), the following error occurs:
POST http://localhost:8100/rest/api/2/issue {"errorMessages":[],"errors":{"reporter":"Reporter is required."}}
This is likely because the reporter needs to be configured differently on Jira Server compared to Jira Cloud.
It would probably make sense to perform a check in the JiraApiClient to determine whether it was called by the JiraCloudService or JiraServerService, and then set the reporter according to the used Service:
JiraServerService: fields.put("reporter", Map.of("name", getCurrentUsername(config)));
JiraCloudService: fields.put("reporter", Map.of("accountId", getCurrentUsername(config)));
Many thanks for your investigation and proposed solution. We will check this.
Thanks for your feedback, @G1t-Happens!
I have updated this pull request with your suggested fix. Could you please verify my changes as I currently do not have access to the JIRA server.
Hey @KzuDemEvin,
I've tried your changes but it is not working for me. For the cloud version I could fix the issue, by replacing
- fields.put("reporter", Map.of("accountId", getJiraConfigs().get(tokenIdentifier)));
with
- fields.put("reporter", Map.of("accountId", jiraApiClient.getCurrentUsername(getJiraConfigs().get(tokenIdentifier))));
I did the same for Jira Server, but there i get this error message:
Thanks for your feedback, @G1t-Happens!
I have updated this pull request with your suggested fix. Could you please verify my changes as I currently do not have access to the JIRA server.
Unfortunately, it doesn't work. Nonetheless, when I configure the reporter attribute as outlined below, both issue trackers operate as expected:
JiraServerService: fields.put("reporter", Map.of("name", getCurrentUsername(tokenIdentifier)));
JiraCloudService: fields.put("reporter", Map.of("accountId", getCurrentUsername(tokenIdentifier)));
Maybe you can verify it too ? @SponsoredByPuma
I've tried your changes but it is not working for me. For the cloud version I could fix the issue, by replacing
- fields.put("reporter", Map.of("accountId", getJiraConfigs().get(tokenIdentifier)));
with
- fields.put("reporter", Map.of("accountId", jiraApiClient.getCurrentUsername(getJiraConfigs().get(tokenIdentifier))));
Yes, you are right. I forgot to convert the config to the accountId. Thanks for pointing that out. Should be fixed now.
Can someone check my changes? @SponsoredByPuma or @G1t-Happens?
I did the same for Jira Server, but there i get this error message:
This seems to be a different bug. Does creating issues with Diveni work on the main branch? And does it now fail on this branch?
Yes, you are right. I forgot to convert the config to the accountId. Thanks for pointing that out. Should be fixed now.
Can someone check my changes? @SponsoredByPuma or @G1t-Happens?
Both Jira issue trackers are now working for me 👍
@KzuDemEvin Jira Cloud now works fine for me, but I still have problems trying to create an issue for the server variant. I've tried it on the main branch and it works fine there. On this branch I still the get the error message that the component field is missing.
@SponsoredByPuma Which Jira Server version are you using? If your version differs from mine (v9.11.0), I will set up the same server on my computer to attempt to reproduce the error.
@Dan1elBox, were you able to reproduce @SponsoredByPuma's issue?
Hi @KzuDemEvin Jira Cloud and the locally installed Jira Server work perfectly for me, but I will try it with the internal Jira Server in the next few days. We believe that could be the issue.
@SponsoredByPuma @Dan1elBox, I have resolved the merge conflicts. Can either of you verify that everything is still working as expected?
@SponsoredByPuma, I think the bug you posted is a local bug. I do not think that my changes caused the error, as there were no code changes made, just refractoring. Can you verify that?
Hey @KzuDemEvin,
The issue still exists, but I guess I know why it is appearing.
So currently on main branch when you create an issue you create an Test Case
On your branch you don't create an Test Case, but an actual User Story.
As you can see here when I try to create a user story manually in Jira, it tells me that components is necessary field.
Important note: Every Project has its own component's in this case it would be "Frontend" and "Service"
Now how to fix it:
You need to add "components" to your fields. It has to be an array I just used an ArrayList<Map<String, Object>>. Now here comes the tricky part. The user has to give information about the component in the frontend, since it is different for every project and for every user story. I guess you could add a drop down where you can select the component. When you got that done, you can just simply add a Map.of("name", YOUR_COMPONENT_NAME) to the ArrayList. Last but not least just have to add the ArrayList to your fields map and that's it.
Here is an example on how I hard coded it for this specific project.
(the component of user story should be Frontend)
(add component to the fields)
Great investigation and analysis, @SponsoredByPuma!
Before we add more and more features of JIRA we should think about fallback on such issues. For example, if something like this company specific field 'component' is required, we show error and redirect to JIRA. Or something similar.
Hi @stritti, I wanted to ask you because you are very knowledgeable about Jira, if it is common practice to split Jira projects into components or if it doesn't happen very often ? So that we might keep this in mind for the future, especially if this happens more frequently.
Good find @SponsoredByPuma, would you mind taking over my pull request since you have better access to Jira?
@KzuDemEvin, I can take care of this PR 😄
