Created
March 26, 2014 16:03
-
-
Save jechlin/9786790 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package examples | |
import com.almworks.jira.structure.api.PermissionLevel | |
import com.almworks.jira.structure.api.StructureException | |
import com.almworks.jira.structure.api.forest.ForestAccessor | |
import com.almworks.jira.structure.api.forest.ForestTransaction | |
import com.atlassian.jira.component.ComponentAccessor | |
import com.atlassian.jira.issue.Issue | |
import com.onresolve.scriptrunner.runner.customisers.PluginModule | |
import com.onresolve.scriptrunner.runner.customisers.WithPlugin | |
import com.almworks.jira.structure.api.StructureServices | |
// Grab only necessary for IDE help, not for runtime | |
@Grab(group = 'com.almworks.jira.structure', module = 'structure-api', version = '8.4.0') | |
// Specify that classes from this plugin should be available to this script | |
@WithPlugin("com.almworks.jira.structure") | |
// Inject plugin module | |
@PluginModule | |
StructureServices structureServices | |
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() | |
//noinspection GroovyVariableNotAssigned | |
def structureManager = structureServices.getStructureManager() | |
Issue issue = issue // provided in binding | |
// should only have one structure for this name - otherwise use a structure ID | |
def structures = structureManager.getStructuresByName("GRV", user, PermissionLevel.VIEW, false) | |
if (structures) { | |
def structure = structures.first() | |
structureManager.updateForest(user, false, new ForestTransaction() { | |
@Override | |
Void transaction(ForestAccessor accessor) throws StructureException { | |
// this adds the issue at the root, to the top of the structure | |
accessor.addIssue(structure.id, issue.id, 0, 0) | |
null | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment