How to save and track time in Jira Software? Watch our joint webinar with Tempo!

Issue Templates for Jira

Jira Server
HOSTING
Last updated Oct 26, 2018

App Integrations

This chapter provides information on how to integrate with Groovy and REST API.

Groovy

You can obtain the id of the used template in Groovy using provided service as on the code below.
All scripts has been tested on ScriptRunner 4.3.12.

Note

Remember to add the annotation @WithPlugin("com.intenso.jira.issue-templates") to use Issue Templates for Jira app.

import pl.intenso.it.utils.export.PublicTemplateSevice
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.component.ComponentAccessor
 
 
@WithPlugin("com.intenso.jira.issue-templates")
def publicTemplateSevice = ComponentAccessor.getOSGiComponentInstanceOfType(PublicTemplateSevice.class)
  
def templateIdByKey = publicTemplateSevice.getAppliedTemplateIdByIssueKey("IT-100");
def templateIdById = publicTemplateSevice.getAppliedTemplateIdByIssueId(10100L);

Below version 6.4.2

import pl.intenso.it.utils.export.AppliedTemplateSevice
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.component.ComponentAccessor
@WithPlugin("com.intenso.jira.issue-templates")
def appliedTemplateSevice = ComponentAccessor.getOSGiComponentInstanceOfType(AppliedTemplateSevice.class)
  
def templateIdByKey = appliedTemplateSevice.getAppliedTemplateIdByIssueKey("IT-100");
def templateIdById = appliedTemplateSevice.getAppliedTemplateIdByIssueId(10100L);

Apply template with Copy set of fields

import pl.intenso.it.utils.export.PublicTemplateSevice
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue;
 
@WithPlugin("com.intenso.jira.issue-templates")
def publicTemplateSevice = ComponentAccessor.getOSGiComponentInstanceOfType(PublicTemplateSevice.class)
   
MutableIssue issue = issue
publicTemplateSevice.applyTemplateToIssue("TEMP-4", issue);

Copy sub-tasks from template

import pl.intenso.it.utils.export.PublicTemplateSevice
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue;
 
@WithPlugin("com.intenso.jira.issue-templates")
def publicTemplateSevice = ComponentAccessor.getOSGiComponentInstanceOfType(PublicTemplateSevice.class)
   
MutableIssue issue = issue
publicTemplateSevice.copySubtasksFromTemplate("TEMP-4", issue, "", null); //Template, current issue, stages and extra due date value

REST API

Request
curl -D- -u admin:admin -X POST –data {see below} -H “Content-Type: application/json” http://localhost:8080/rest/api/2/issue
Data
 {"fields": {
    "project":
    {
       "key": "EXMP"
    },
    "summary": "Issue created from REST.",
    "issuetype": {
       "name": "Bug"
    },
    "customfield_10000" : "7"
  }