Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Add Smart Checklist Templates to your issues via different tools available in Jira - ScripRunner for Jira, Automation for Jira, JMWE.

Contents πŸ‘‡πŸΌ

Steps on how to apply the Smart Checklist Template via Automation for Jira

πŸ’‘HINT: This is just an example of a use case with Issue created trigger. You can select any other available trigger based on your needs.

  1. Create a personal access token

    1. Navigate to User icon β†’ Profile β†’ Personal Access Tokens β†’ Create Token

      image-20240212-154345.png
    2. Copy token value

  2. Go to Project Settings β†’ Project Automation β†’ click Create rule: (or go to Administration β†’ System β†’ Automation rules β†’ click Create rule: )

    image-20240212-154212.png

  3. Create a trigger

    1. Choose Issue created

    2. Save

      image-20240213-125247.png

  4. Add component - New action

    image-20240213-125359.png

    1. Choose Send web request as the first action.

      image-20240213-125435.png
    2. Fill in the fields with the following values:

Webhook URL

http://Jira_base_URL/rest/railsware/1.0/checklist?issueKey={{issue.key}}

Headers

Authorization with Bearer token (mentioned in step 1)

HTTP method

GET

Webhook body

Empty

Wait for Response

Check this option

image-20240213-142250.png

c. Save

  1. Add component - New action

    image-20240213-125919.png

    1. Choose Send web request as the second action

      image-20240213-125946.png
    2. Fill in the fields with the following values:

Webhook URL

http://Jira_base_URL/rest/railsware/1.0/checklist/{{webhookResponse.body.checklists.get(0).checklistId}}/template/${templateId}

Where ${templateId} should be replaced by the actual Smart Checklist template id

Headers

Authorization

Bearer + token (mentioned in step 1)

HTTP method

POST

Webhook body

Empty

Wait for Response

Don’t check this option

☝🏼NOTE: You can find the Template ID by going to Issue β†’ Smart Checklist β†’ 3 dots menu β†’ Manage Templates β†’ Expand the Template you are looking for β†’ Copy the Template ID βœ…

Or going to Jira Administration β†’ Manage apps β†’ Smart Checklist Settings β†’ Templates tab β†’ Find needed template β†’ Click on the Template you are looking for β†’ Copy the Template ID βœ…

  • image-20240212-161048.png

Check out more about Templates IDs here β†’https://railsware.atlassian.net/wiki/spaces/CHKSDC/pages/edit-v2/4085284902?draftShareId=60155a82-23ad-49b1-8075-4f1126d53d8b

image-20240213-142327.png

c. Save

  1. Name your new Automation and Turn it on

    image-20240213-130543.png

You're done! Now every time an issue is created, the proper template will be added to your Smart Checklist πŸŽ‰

Steps on how to apply the Smart Checklist template via ScriptRunner

  1. Go to Jira Administration β†’ ScriptRunner β†’ Console

    image-20240213-145801.png
  2. Add the following script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.sal.api.UrlMode
import com.atlassian.sal.api.net.Request
import com.atlassian.sal.api.net.TrustedRequestFactory
import groovy.json.JsonSlurper
import groovyx.net.http.URIBuilder

def testIssueKey = "TEST-1"
def templateId = 10

class SmartChecklistAPI {
    def trustedRequestFactory = ComponentAccessor.getOSGiComponentInstanceOfType(TrustedRequestFactory.class)
	def applicationProperties = ComponentAccessor.getApplicationProperties()

    long getChecklistId(String issueKey) {
        def url = applicationProperties.getString("jira.baseurl") + '/rest/railsware/1.0/checklist?issueKey=' + issueKey
        def checklistResponse = sendGetRequest(url)
        assert checklistResponse instanceof Map
        assert checklistResponse.checklists instanceof List
        assert checklistResponse.checklists.get(0) instanceof Map
        return (long) checklistResponse.checklists.get(0).get("checklistId")
    }

    void applyTemplate(Long checklistId, Long templateId) {
        def url = applicationProperties.getString("jira.baseurl") + '/rest/railsware/1.0/checklist/' + checklistId + '/template/' + templateId
        sendPostRequest(url)
    }

    private Object sendGetRequest(String url) {
        def request = trustedRequestFactory.createTrustedRequest(Request.MethodType.GET, url)
        def host = new URIBuilder(url).host
        request.addTrustedTokenAuthentication(host) 
        def responseBody = request.execute()
        return new JsonSlurper().parseText(responseBody)
    }

    private void sendPostRequest(String url) {
        def request = trustedRequestFactory.createTrustedRequest(Request.MethodType.POST, url)
        def host = new URIBuilder(url).host
        request.addTrustedTokenAuthentication(host) 
        request.execute()
    }
}

def checklistAPI = new SmartChecklistAPI()

def checklistId = checklistAPI.getChecklistId(testIssueKey)
checklistAPI.applyTemplate(checklistId, templateId)

Where testIssueKey and templateId should be changed accordingly.

  1. Click Run

πŸ’‘HINT: This is just an example of a use case using Console. You can also use this script in other ScriptRunner places, like Workflows etc. In such a case replace value of testIssueKey with issue.key to get a reference of the current issue.

Steps on how to apply the Smart Checklist template via JMWE

  1. Navigate to Jira Administration β†’ Manage apps β†’ Jira Misc Workflow Extensions Settings β†’ Select Groovy console

    image-20240213-152244.png
  2. Add the following script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.sal.api.UrlMode
import com.atlassian.sal.api.net.Request
import com.atlassian.sal.api.net.TrustedRequestFactory
import groovy.json.JsonSlurper
import groovyx.net.http.URIBuilder

def testIssueKey = "TEST-1"
def templateId = 10

class SmartChecklistAPI {
    def trustedRequestFactory = ComponentAccessor.getOSGiComponentInstanceOfType(TrustedRequestFactory.class)
	def applicationProperties = ComponentAccessor.getApplicationProperties()

    long getChecklistId(String issueKey) {
        def url = applicationProperties.getString("jira.baseurl") + '/rest/railsware/1.0/checklist?issueKey=' + issueKey
        def checklistResponse = sendGetRequest(url)
        assert checklistResponse instanceof Map
        assert checklistResponse.checklists instanceof List
        assert checklistResponse.checklists.get(0) instanceof Map
        return (long) checklistResponse.checklists.get(0).get("checklistId")
    }

    void applyTemplate(Long checklistId, Long templateId) {
        def url = applicationProperties.getString("jira.baseurl") + '/rest/railsware/1.0/checklist/' + checklistId + '/template/' + templateId
        sendPostRequest(url)
    }

    private Object sendGetRequest(String url) {
        def request = trustedRequestFactory.createTrustedRequest(Request.MethodType.GET, url)
        def host = new URIBuilder(url).host
        request.addTrustedTokenAuthentication(host) 
        def responseBody = request.execute()
        return new JsonSlurper().parseText(responseBody)
    }

    private void sendPostRequest(String url) {
        def request = trustedRequestFactory.createTrustedRequest(Request.MethodType.POST, url)
        def host = new URIBuilder(url).host
        request.addTrustedTokenAuthentication(host) 
        request.execute()
    }
}

def checklistAPI = new SmartChecklistAPI()

def checklistId = checklistAPI.getChecklistId(testIssueKey)
checklistAPI.applyTemplate(checklistId, templateId)

Where testIssueKey and templateId should be changed accordingly.

  1. Click the Test Groovy script button

    image-20240213-152433.png
  2. Enter Issue Key where you want to apply template β†’ Click Test

    image-20240213-152552.png
  3. You will see a message πŸš€

    image-20240213-152659.png

πŸ’‘HINT: This is just an example of a use case using Groovy Console. You can also use this script in other JMWE places, like JMWE Workflow extentions etc. In such a case replace value of testIssueKey with issue.key to get a reference of the current issue.


πŸ“« Don’t hesitate to get in touch with us for any questions or feature requests!

  • No labels