ad-build-test / BuildSystem

Testing buildsystem repo
0 stars 0 forks source link

Bug tracking issue creation - JIRA #39

Open pnispero opened 3 days ago

pnispero commented 3 days ago

Bug tracking issue creation - JIRA

Research

Look into how we can implement JIRA to create issues add comments etc.

  1. The crucial aspect to look into is authorization first.
  2. How can we get the backend to have write access to the projects in JIRA, can we do something similar to github where we have a 'github app' that can be installed into an organization and then have access to the repos within that organization?

TODO

pnispero commented 3 days ago

Update

  1. Messaged JIRA administrators on what's possible with JIRA authorization and API access. https://slacprod.servicenowservices.com/now/nav/ui/classic/params/target/incident.do%3Fsys_id%3D8ef7cfb087f11214f2770f280cbb35ca%26sysparm_stack%3Dincident_list.do%3Fsysparm_query%3Dactive%3Dtrue
  2. There exists an Atlassian supported JIRA framework for java spring (https://developer.atlassian.com/cloud/jira/platform/connect-frameworks-and-tools/)
pnispero commented 1 day ago

Update

There are 2 options for authorization:

  1. OAuth v2
  2. PAT (Personal access token) See jira documentation for more info.

PAT is the method suggested from JIRA administrators, and for good reason. It boils down to PAT's are more simple, easier to manage, and perfect for CI/CD for just issue creation/reporting. Whereas OAuth is overkill for what we would be using it for and has more complexity and overhead.

pnispero commented 22 hours ago

Update

We are going with PAT. And requested for a psuedo user account adbuild on Jira - ticket.

New plan

  1. With the new adbuild account, we can create a PAT for that and store it in the backend vault.
  2. Every project that wants their Jira project integrated to BuildSystem will just need to add the adbuild group which has the adbuild user that'll give it permissions to create/modify issues.
  3. We are using group adbuild with only one user adbuild because a group uses the same permissions globally, whereas a user can be configured for each project

    Use cases (todo)

  4. Create Jira issue based off cater ID
    • user calling the CLI command bs create issue would need to specify cater ID as normal, but also what Jira project. Alternatively we can have the Jira project in the component db and just use that.
  5. Add build/test report of PR on Jira issue automatically
    • The concern here is how do we know what Jira issue is associated with the PR?
    • Potential solution: When the user creates branch bs create branch, and a branch is always a fix, feat, or dev. If its a fix or feat, then user must provide issue number, and in the case of Jira, the issue number is the project-key-# like EEDSWCM-7. And having that info is all we need to know what issue in Jira is the branch associated with.
pnispero commented 21 hours ago

Sample curl request to create an issue

curl -X 'POST' \
"https://jira.slac.stanford.edu/rest/api/2/issue/" \
-H "Authorization: Bearer <PAT>" \
-H "Content-Type: application/json" \
-d '{
    "fields": {
       "project":
       {
          "key": "EEDSWCM"
       },
       "summary": "Testing Jira API.",
       "description": "Creating of an issue using project keys and issue type names using the REST API",
       "issuetype": {
          "name": "Task"
       }
   }
}'

Response:

{"id":"79423","key":"EEDSWCM-86","self":"https://jira.slac.stanford.edu/rest/api/2/issue/79423"}