sailuh / kaiaulu

An R package for mining software repositories
http://itm0.shidler.hawaii.edu/kaiaulu
Mozilla Public License 2.0
20 stars 13 forks source link

Improve JIRA API Download Documentation #252

Closed carlosparadis closed 7 months ago

carlosparadis commented 12 months ago

This costed me some time to figure out, so it should go on the Notebook involving JIRA Download.

Kaiaulu now has a JIRA issue tracker (https://sailuh.atlassian.net/jira/software/c/projects/SAILUH/issues) for experimenting with the API downloader, as I plan to expand this in the future.

Screen Shot 2023-11-20 at 11 34 13 PM

One issue with the free version of JIRA is that it is closed access by default. To the best of my understanding, we can't also make it public. This, in turn means, the downloader Notebook will fail without some form of authentication.

Screen Shot 2023-11-20 at 11 33 08 PM

This page explains how to create an API token, for the project:

https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/

It seems some APIs expect the token to be added to the header, but JIRA API Token merely can serve as a replacement to the password itself. So, the example flag using curl is user. This is the same parameter one would type their username:password. Therefore, for JirAgileR crawler, the following code can be used:

json_issue_comments <- get_jira_issues(jql_query = paste0("project='",issue_tracker_project_key,"'"),
                fields = c("summary",
                           "description",
                           "creator",
                           "assignee",
                           "reporter",
                           "issuetype",
                           "status",
                           "resolution",
                           "components",
                           "created",
                           "updated",
                           "resolutiondate",
                           "comment"),
                username = "your_username",
                password = "your_api_token",
                verbose=TRUE,
                as.data.frame = FALSE)
jsonlite::write_json(json_issue_comments,save_path_issue_tracker_issue_comments)

In essence, basically the existing code plus the two additional parameters for username and password. The Status code we want it to return is 200.

carlosparadis commented 12 months ago

@waylonho Not sure if you already had this worked out but, it is here if you need to do some more testing.

carlosparadis commented 7 months ago

Example API call that works on browser if you are already logged in:

https://sailuh.atlassian.net/rest/api/2/search?jql=project%3D%27SAILUH%27%20AND%20issueKey%20%3E%3D%20SAILUH-1%20AND%20issueKey%20%3C%3D%20SAILUH-3&fields=summary%2Cdescription%2Ccreator%2Cassignee%2Creporter%2Cissuetype%2Cstatus%2Cresolution%2Ccomponents%2Ccreated%2Cupdated%2Cresolutiondate%2Cpriority%2Cvotes%2Cwatches%2Cversions%2CfixVersions%2Clabels&startAt=0&maxResults=50

Use Pretty Print to decompose: https://urlprettyprint.com/

carlosparadis commented 7 months ago

The Kaiaulu JIRA Sandbox is now used in our JIRA Notebook as part of PR #279. I am therefore closing this issue.