Quantcast
Channel: Active questions tagged atlassian-plugin-sdk - Stack Overflow
Viewing all articles
Browse latest Browse all 279

The automation rule fired when an update is made does not lead to the correct execution of the code

$
0
0

 I am using an automation rule and I have used issue updated as an automation trigger for my rule and it's not working, I receive the message, the issue does not have any components even though the issue does have components. 

You can see it in these screenshots:

enter image description hereenter image description hereenter image description hereenter image description hereHere is the code which is supposed to be executed based on an issue update. I printed the issue and I have gotten the following: =====MOUNA CAMELIA ISSUE:::: SF-437 ISSUE COMPONENTS []

The issue components are empty which is obviosuly wrong. My issue does have components.

package SuperFeatureimport com.atlassian.jira.issue.Issueimport org.apache.log4j.Loggerimport com.atlassian.jira.project.version.Versionimport com.atlassian.jira.bc.project.component.ProjectComponentimport com.atlassian.jira.bc.project.component.ProjectComponentManagerimport com.atlassian.jira.security.JiraAuthenticationContextimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.label.LabelManager  def log = Logger.getLogger('atlassian-jira.log')List < String > componentList = new ArrayList < String > ()List < ProjectComponent > finalComponentList = new ArrayList < ProjectComponent > ()def projectNames = [ 'WF', 'BF', 'EF', 'YF', 'CLTF']log.warn("=====MOUNA CAMELIA ISSUE:::: "+ issue +" ISSUE COMPONENTS "+issue.getComponents())if (issue.getComponents().size() == 0) {   issue.update {     String text = "Issue does not have any components\n"     setCustomFieldValue('Execution Summary', text )   }} else if (issue.getFixVersions().size() == 0) {   issue.update {     String text = "Issue does not have any fix versions\n"     setCustomFieldValue('Execution Summary', text)   }} else {   int componentSize = issue.getComponents().size()     int generatedIssuesCounter= 0   for (ProjectComponent component: issue.getComponents()) {            String componentName = component.getName()           def shortenedComponentName = componentName.substring(componentName.indexOf("-") + 1)           def projectName = componentName.substring(0, componentName.indexOf("-"))                                 if(projectNames.contains(projectName)){                                     def newIssueproject = ComponentAccessor.projectManager.getProjectObjByKey(projectName)             //log.warn("MOUNA CAMELIA found--"+found+"--NEW LIST SIZE: "+newList)             List < ProjectComponent > newList = new ArrayList < > (newIssueproject.getComponents());             def found = newList.any {               it.getName().equals(shortenedComponentName)             }             if (found) {               componentList.add(componentName+" ===> WILL BE GENERATED")               finalComponentList.add(component)               generatedIssuesCounter++             } else{               componentList.add(componentName+" ===> CANNOT BE GENERATED")             }             }         }      issue.update {     String text = "The super feature " + issue +" will be split into " + generatedIssuesCounter +" features, one for each component:\n"        text = text + componentList.join("\n")   ;     // Partition a list into list of lists size 3         setCustomFieldValue('Execution Summary', text)   }}  

Viewing all articles
Browse latest Browse all 279

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>