Skip to content

Instantly share code, notes, and snippets.

@qoomon
Last active January 23, 2024 09:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save qoomon/d49560c7ef805ad409f545ed4964d5c8 to your computer and use it in GitHub Desktop.
Save qoomon/d49560c7ef805ad409f545ed4964d5c8 to your computer and use it in GitHub Desktop.
Jira Script Runner - Behaviour - Issue Templates, Restrict Links Types
// ------------------------------------------
// ---- Set default Description -------------
// ------------------------------------------
def defaultDescriptions = [
Story: """
*As a* USER
*I want* FEATURE
*so that* BENEFIT
h4. Acceptance Criterias
# NONE
h4. Infos
* NONE
"""
]
if (! underlyingIssue?.description) {
getFieldById("description")?.formValue = defaultDescriptions[issueContext.issueType.name]?.stripIndent()
}
// ------------------------------------------
// ---- Set Allowed Link Types --------------
// ------------------------------------------
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkTypeManager
def allowedLinkNames = [
// --- Jira Defaults ---
"relates to", "relates to",
"duplicates", "is duplicated by",
"blocks", "is blocked by",
"clones", "is cloned by",
]
def allowedLinks = ComponentAccessor.getComponent(IssueLinkTypeManager).getIssueLinkTypes(false)
.findAll { it.outward in allowedLinkNames || it.inward in allowedLinkNames }
getFieldById("issuelinks-linktype").setFieldOptions(allowedLinks.collectEntries {
[ (it.outward): it.outward, (it.inward): it.inward ]
})
// ------------------------------------------
// ---- Set Allowed Resolutions -------------
// ------------------------------------------
import com.atlassian.jira.component.ComponentAccessor
def allowedResolutionNames = [
// --- Jira Defaults ---
"Fixed",
"Duplicate",
"Won't Fix",
"Incomplete",
"Cannot Reproduce",
]
def allowedResolutions = ComponentAccessor.constantsManager.resolutions
.findAll { it.name in allowedResolutionNames }
getFieldById("resolution").setFieldOptions(allowedResolutions.collect {
it.name
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment