Jira
Jira CLI
This CLI is provided to perform batch processing and ticket assignment using the Jira Platform. It is designed to perform bulk processing of RegScale issues to create, update, and otherwise sync with Jira and vice versa to perform automated ticket assignment. The CLI currently supports the below functionality:
issues
- syncs issues from RegScale and auto-assigns tickets in Jira while cross-linking their IDs
Init.yaml Configuration
There are multiple pieces of information needed to configure the Jira integration via the CLI:
jiraUrl
- base URL of your Jira instancejiraUserName
- Jira User NamejiraApiToken
- Jira API token generated for this user namemaxThreads
- The total number of threads the application is allowed to use for bulk processing. The default value is 1000. (NOTE: Changing this number can have a negative or positive impact on performance.)
The first step is to get the Jira Url for your organization's account. This is the base URL of your Atlassian Jira instance. An example Jira Url is as follows: https://team-9999996538008.atlassian.net/
.
Now, create an API key in Jira. Click the "Settings" icon in the header, then select "Atlassian Account Settings". Next, select the "Security" tab on the left and then click "Create or Manage API Token". Click the "Create API Token" button to create a token for the CLI and copy it for later use in the init.yaml
file.
Issue Processing Workflow
The CLI currently supports processing RegScale issues to create Jira tickets. The issue processing workflow is shown below:
- The user first logs into RegScale via the CLI to set the access token or otherwise creates a service account as described in the CLI Login documentation
- The user then calls the CLI to process Jira tickets while setting the following flags:
regscale_id
- the ID # of the RegScale record associated with these issuesregscale_module
- the RegScale module of the record associated with these issues, please view RegScale Modules for options.jira_project
- specifies the project to open the Jira ticket againstjira_issue_type
- specifies the type of issue ticket you want created in Jirasync_attachments
- Whether to sync attachments between Jira and RegScale, defaults to True
- The CLI then retrieves all existing issues in RegScale for the key value pair provided above
- The CLI then retrieves all issues in Jira (paging through 100 at a time until all are retrieved)
- The CLI then processes through all retrieved Jira issues and does the following:
- Sees if Jira has the issue in RegScale, if not an issue is created in Jira with the provided
issue_type
and the issue in RegScale is updated to include the new Jira issue ID - Sees if RegScale has all the issues from Jira, if not it is created in RegScale with the information associated with the issue in Jira
- If the issues already exist in both Jira and RegScale they are compared against one another and updated
- When using
sync_attachments
as True, the attachments for both the RegScale issue and Jira issue, are compared to prevent duplication and the attachments will match in both Regscale and Jira
- Sees if Jira has the issue in RegScale, if not an issue is created in Jira with the provided
The CLI provides detailed logging throughout the process to indicate progress and to provide troubleshooting in case of problems.
Issue CLI Command Example
The following command provides an example of processing Jira tickets for a given RegScale System Security Plan (SSP). These commands can be easily adapted for the customer's specific use case. The steps are shown below:
- Log into RegScale to set the token which is good for 24 hours and will secure all future RegScale API calls (NOTE: You can skip this step if you are using a RegScale Service Account)
regscale login
- Process the appropriate level of issues for the given record
regscale jira issues --regscale_id=5 --regscale_module="securityplans" --jira_project="AT" --jira_issue_type="[System] Incident"
Init.yaml Example
For a basic Jira integration with RegScale, the following init.yaml
structure is necessary (example/notional key structure shown below, replace with actual customer keys):
domain: https://mycompany.regscale.com
token: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVC38.eyJzdWIiOiJob3dpZWF2cCIsImp0aSI6ImI0NDIxMjRhLTYxOWEtNGI1Mi1hMzUzLTA5YzdjZTRmM2JmOCIsImlhdCI6MTY0NDc4NzY4MiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbmFtZWlkZW50aWZpZXIiOiJjOWY1NzllMi1hOGM4LTRjMDItOGU5MS1jZTEyMmExYWE1MTciLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiaG93aWVhdnAiLCJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL3JvbGUiOiJBZG1pbmlzdHJhdG9yIiwibmJmIjoxNjQ0Nzg3NjgyLCJleHAiOjE2NDQ4NzQwODIsImlzcyI6IkF0bGFzIiwiYXVkIjoiaHR0cDovL2xvY2FsaG9zdDo1MDAwLyJ9.SkjmRktGLkljysVeoRqcx_hHiVR2gjcA2uZiSJbVkPc
maxThreads: 1000
userId: c9f579e2-a8c9-4c02-8e91-ce122a1aa518
jiraUrl: https://team-99999999999999.atlassian.net
jiraUserName: [email protected]
jiraApiToken: 99rtYi34trydt345ynb
Building a Bash Script to Execute the CLI
You can chain together RegScale CLI commands using scripts. These scripts could be in Bash, Python, PowerShell, etc. Below is an example Bash file (named "regscaleScheduler.sh") in Ubuntu for executing the Jira CLI that pulls all issues after authenticating and assigns them to a specific project in Jira:
#!/bin/sh
regscale login
regscale jira issues --regscale_id=5 --regscale_module="securityplans" --jira_project="AT" --jira_issue_type="Bug"
To execute the Bash file, run this command: . regscaleScheduler.sh
. You can chain together any arbitrary set of CLI commands to have them execute sequentially.
Updated 11 months ago