Hi,
I got the following script (works) that makes sure all the linked issues to epic are closed.
If not the Epic cant get closed.
I want to limit it to a specific link type: ("Issues in Epic").
Does anyone know how to make it happen?
The code:
Hi @Etai Leers,
from your last feedback, I think you could try changing in your original code the line:
def found = issueLinkManager.getOutwardLinks(issue.id).any
with this:
def found = issueLinkManager.getOutwardLinks(issue.id).findAll { it.issueLinkType.name == 'Epic-Story Link' }.any
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please could you run this in ScriptRunner Console:
import com.atlassian.jira.component.ComponentAccessor
def issue = ComponentAccessor.issueManager.getIssueObject("SAM-36")
ComponentAccessor.issueLinkManager.getOutwardLinks(issue.id).each { log.error it.issueLinkType.name }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Etai Leers,
you could try changing this code:
{
it?.destinationObject?.getStatus().getName() != 'Done' &&
it?.destinationObject?.getIssueType().getName() != 'Epic'
}
with the following:
{
it?.destinationObject?.status.name != 'Done' &&
it?.destinationObject?.issueType.name != 'Epic' &&
it?.destinationObject?.description == 'Issues in Epic'
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Now its not working it all :)
(When I replace between the code snippets).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, and what happens if you replace with this:
{
it?.destinationObject?.status.name != 'Done' &&
it?.destinationObject?.issueType.name != 'Epic' &&
it?.sourceObject?.description == 'Issues in Epic'
}
?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I need more elements to help you.
Please, could you report what you see in the Issue Linking page (YOUR_JIRA_BASE_URL/secure/admin/ViewLinkTypes!default.jspa)?
In particular, the rows where you see 'Issues in Epic' (better if you attach an image).
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually, I don't see the link type in the Jira Issue Linking page.
Its that one:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Etai Leers , yes, it's an outwardlink of type: 'Epic-Story Link'; for this reason, I asked you to report here the result of this script:
import com.atlassian.jira.component.ComponentAccessor
def issue = ComponentAccessor.issueManager.getIssueObject("SAM-36")
ComponentAccessor.issueLinkManager.getOutwardLinks(issue.id).each { log.error it.issueLinkType.name }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
2022-06-28 13:06:52,046 DEBUG [support.DefaultListableBeanFactory]: Creating instance of bean 'com.onresolve.scriptrunner.canned.jira.workflow.validators.CustomScriptValidator'
2022-06-28 13:06:52,046 DEBUG [support.DefaultListableBeanFactory]: Returning cached instance of singleton bean 'scriptRunnerImpl'
2022-06-28 13:06:52,046 DEBUG [support.DefaultListableBeanFactory]: Returning cached instance of singleton bean 'configuredValidatorFactory' 2022-06-28 13:06:52,046 DEBUG [support.DefaultListableBeanFactory]: Returning cached instance of singleton bean 'configuredObjectMapper'
2022-06-28 13:06:52,046 DEBUG [support.DefaultListableBeanFactory]: Autowiring by type from bean name 'com.onresolve.scriptrunner.canned.jira.workflow.validators.CustomScriptValidator' via constructor to bean named 'scriptRunnerImpl'
2022-06-28 13:06:52,046 DEBUG [support.DefaultListableBeanFactory]: Autowiring by type from bean name 'com.onresolve.scriptrunner.canned.jira.workflow.validators.CustomScriptValidator' via constructor to bean named 'configuredValidatorFactory'
2022-06-28 13:06:52,046 DEBUG [support.DefaultListableBeanFactory]: Autowiring by type from bean name 'com.onresolve.scriptrunner.canned.jira.workflow.validators.CustomScriptValidator' via constructor to bean named 'configuredObjectMapper'
2022-06-28 13:06:52,046 DEBUG [support.DefaultListableBeanFactory]: Finished creating instance of bean 'com.onresolve.scriptrunner.canned.jira.workflow.validators.CustomScriptValidator'
2022-06-28 13:06:52,069 DEBUG [acme.ListLinks]: TEST
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Payload:
{"canned-script": "com.onresolve.scriptrunner.canned.jira.workflow.validators.CustomScriptValidator (java.lang.String)", "class.name": "com.onresolve.jira.groovy.GroovyValidator (java.lang.String)", "issue": "SAM-35 (com.atlassian.jira.issue.IssueImpl)", "transientVars": { "issue": "SAM-35 (com.atlassian.jira.issue.IssueImpl)", "configuration": "com.opensymphony.workflow.config.DefaultConfiguration@66b1b2fb", "proj": "Project: SAM (com.atlassian.jira.project.ProjectImpl)", "project": "[GenericEntity:Project][name,Sample][assigneetype,3][description,][projecttype,software][id,10600][counter,26][avatar,10324][originalkey,SAM][url,null][lead,automation4jira][key,SAM] (org.ofbiz.core.entity.GenericValue)", "currentSteps": "[SimpleStep@6[owner=, actionId=0, status=Done]] (java.util.ArrayList)", "store": "com.opensymphony.workflow.spi.ofbiz.OfbizWorkflowStore@e97f036", "descriptor": "com.atlassian.jira.workflow.ImmutableWorkflowDescriptor@48aede84", "userKey": "etai.leers (java.lang.String)", "originalAssigneeId": "null (org.codehaus.groovy.runtime.NullObject)", "entry": "com.opensymphony.workflow.spi.SimpleWorkflowEntry@20490f0c", "context": "com.opensymphony.workflow.basic.BasicWorkflowContext@d83d385", "originalissueobject": "SAM-35 (com.atlassian.jira.issue.IssueImpl)", "actionId": "31 (java.lang.Integer)", "pkey": "SAM (java.lang.String)", "transaction": "com.atlassian.jira.transaction.TransactionSupportImpl$TransactionImpl@7a95eec6" }, "log": "org.apache.log4j.Logger@2c8b3cf0", "originalIssue": "SAM-35 (com.atlassian.jira.issue.IssueImpl)", "invalidInputException": "null (org.codehaus.groovy.runtime.NullObject)", "\u00a3beanContext": "com.onresolve.scriptrunner.beans.BeanFactoryBackedBeanContext@698c9822" }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sorry, I meant what the reported script prints, once run from Script console?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nope it runs from a workflow validator.
Once trying to make a transition from "In progress" status to "Done" status. 😊
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The test I proposed above was to understand whether or not an issuelinktype called Epic-Story Link is present on the issue you try to validate.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.