Diveni icon indicating copy to clipboard operation
Diveni copied to clipboard

#254 Jira Cloud Support

Open KzuDemEvin opened this issue 2 years ago • 17 comments

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

KzuDemEvin avatar Aug 11 '23 12:08 KzuDemEvin

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)));

G1t-Happens avatar Sep 05 '23 23:09 G1t-Happens

Many thanks for your investigation and proposed solution. We will check this.

stritti avatar Sep 09 '23 15:09 stritti

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.

KzuDemEvin avatar Sep 18 '23 10:09 KzuDemEvin

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: image

SponsoredByPuma avatar Sep 20 '23 12:09 SponsoredByPuma

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

G1t-Happens avatar Sep 20 '23 13:09 G1t-Happens

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: image

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?

KzuDemEvin avatar Sep 20 '23 15:09 KzuDemEvin

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 👍

G1t-Happens avatar Sep 20 '23 19:09 G1t-Happens

@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 avatar Sep 21 '23 07:09 SponsoredByPuma

@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 avatar Oct 12 '23 07:10 Dan1elBox

@Dan1elBox, were you able to reproduce @SponsoredByPuma's issue?

KzuDemEvin avatar Oct 19 '23 08:10 KzuDemEvin

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.

Dan1elBox avatar Oct 19 '23 13:10 Dan1elBox

@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?

KzuDemEvin avatar Oct 24 '23 17:10 KzuDemEvin

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 image On your branch you don't create an Test Case, but an actual User Story. image As you can see here when I try to create a user story manually in Jira, it tells me that components is necessary field. image Important note: Every Project has its own component's in this case it would be "Frontend" and "Service" image

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. image (the component of user story should be Frontend) image (add component to the fields)

SponsoredByPuma avatar Oct 25 '23 11:10 SponsoredByPuma

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.

stritti avatar Oct 25 '23 15:10 stritti

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.

Dan1elBox avatar Nov 02 '23 10:11 Dan1elBox

Good find @SponsoredByPuma, would you mind taking over my pull request since you have better access to Jira?

KzuDemEvin avatar Nov 02 '23 20:11 KzuDemEvin

@KzuDemEvin, I can take care of this PR 😄

SponsoredByPuma avatar Nov 03 '23 09:11 SponsoredByPuma