Last active
January 23, 2024 09:30
-
-
Save qoomon/d49560c7ef805ad409f545ed4964d5c8 to your computer and use it in GitHub Desktop.
Jira Script Runner - Behaviour - Issue Templates, Restrict Links Types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------------------------------------ | |
// ---- 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