...
Code Block | ||||
---|---|---|---|---|
| ||||
import com.deniz.jira.versioning.subcomponents.SubcomponentsService; import com.deniz.jira.versioning.subcomponents.ComponentHierarchy; import com.onresolve.scriptrunner.runner.customisers.PluginModule; import com.onresolve.scriptrunner.runner.customisers.WithPlugin; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.component.ComponentAccessor; import com.deniz.jira.versioning.bundles.BundleService; import com.deniz.jira.versioning.CmpVersionMappingService; import com.deniz.jira.versioning.bundles.BundleNameFormatter; import com.atlassian.jira.bc.issue.comment.CommentService; import com.atlassian.jira.project.version.VersionManager @WithPlugin("com.deniz.jira.versioning") @PluginModule BundleService bundleService; @WithPlugin("com.deniz.jira.versioning") @PluginModule CmpVersionMappingService cmpVersionMappingService; //get the issue def im = ComponentAccessor.getIssueManager(); def versionManager = ComponentAccessor.getVersionManager(); def issue = im.getIssueObject("ERP-23"); def versions = issue.getAffectedVersions(); //for found in bundle we use affect(s) version, for fixed in bundle we use fix versions def components = issue.getComponents(); if (versions.size() == 0 || components.size() == 0) { return; } //def bundleNameFormatter = new BundleNameFormatter(cmpVersionMappingService, null, null); FOR VERSIONS BEFORE 1.312.0 def bundleNameFormatter = new BundleNameFormatter(versionManager, null, null); //FOR VERSIONS 1.312.0+ //get all bundles (affected) containing the version and component pairs of the issue def affectedBundles = bundleService.getBundles(bundleNameFormatter, versions, components); System.out.println("affectedBundles:"+affectedBundles) //get content of bundle as String def tableMarkup = new StringBuilder("||Component||Version||\n"); for (bundle in affectedBundles) { //def bundleContents = cmpVersionMappingService.getComponentsOfBundle(bundle.getId()); FOR VERSIONS BEFORE 1.312.0 def bundleContents = bundleService.getComponentsOfBundle(bundle.getId()); //FOR VERSIONS 1.312.0+ for (componentVersion in bundleContents) { System.out.println("component:" + componentVersion.getComponentName()); System.out.println("version:" + componentVersion.getVersionName()); tableMarkup.append("|" + componentVersion.getComponentName()); tableMarkup.append("|" + componentVersion.getVersionName() + "|\n"); } } System.out.println(tableMarkup) //add bundle table as a comment to issue def cm = ComponentAccessor.getCommentManager(); def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(); cm.create(issue, user, tableMarkup.toString(), true) |
...