/** This example script console script shows how you can get the labels off an issue and copy them over to all of its linked issues.* "All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner* license shall be granted a non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed or amended and must be included in any circumstances where the code snippet is shared by You or a third party." */// Specify the IssueKeydefissueKey='<InsertIssueKeyHere>'// Make a rest call to return the Issuedefissue=get('/rest/api/2/issue/'+issueKey).header('Content-Type','application/json').asObject(Map).body// Get the labels from the issue deflabels=issue.fields.labels// Find the linked issuesdeflinkedIssues=issue.fields.issuelinks// Define a loop counterdefloopCounter=0// Loop over each linked issuelinkedIssues.each{// Iterate the loop counter on each iteration of the looploopCounter++// Update each linked issue to set the labels using the key for each linked issuedefupdateLinkedIssue=put('/rest/api/2/issue/'+it.outwardIssue.key).header('Content-Type','application/json').body([fields:[labels:labels]]).asString()// Print to the log tabs what iteration the loop is on and the key of the issue that was updated println"Iteration ${loopCounter} of the loop set the labels on the ${it.outwardIssue.key} issue."}return"The Script has completed updating the labels succsfully on ${loopCounter} issues. \nPlease see the 'Logs' tab for more information on what issues were updated."
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.