Snippets

Adaptavist Script Console Transitions Issues Returned from a JQL Search

Updated by Kristian Walker

File snippet.groovy Modified

  • Ignore whitespace
  • Hide word diff
 
 def jqlQuery = "<AddJQLQueryHere>"
 
-// Get all issues matching a specified version in the Development Complete
+// Get all issues matching the specified JQL Query
 def allmatchingIssues = get("/rest/api/2/search")
         .queryString("jql", jqlQuery)
         .asObject(Map)
         .body
         .issues as List<Map>
 
-// Log out the number of issues returned by the search
+// Log out the number of issues returned by the JQL search
 logger.info("The number of issues returned by the JQL search = : ${allmatchingIssues.size()}")
 
-// Log out the map of issues returned by the search.
+// Log out the map of issues returned by the JQL search.
 logger.info("The returned issues are " + allmatchingIssues)
 
 // Iterate over each issue returned
 allmatchingIssues.each { it ->
 
-    // Get the issue object for each issue returned within the search
+    // Get the issue object for each issue returned within the JQL search
     def issue = get('/rest/api/2/issue/' + it.key)
             .header('Content-Type', 'application/json')
             .asObject(Map)
 
-    // Check if the issue in the issue type is Deployment status
+    // Check if the issue in the issue type is in the specified status
     if (issue.body.fields.status.name == "${status}") {
-        // check if the issue is of issue type Development Completed if the issuetype = Deployment
+        // check if the issue is of the specified issue type
         if (issue.body.fields.issuetype.name == "${issueType}") {
-            // If  all of  the conditions are met transition the issue to the Ready for Testing status
+            // If  all of  the conditions are met transition the issue
             def transition = post('/rest/api/2/issue/' + it.key + '/transitions')
                     .header("Content-Type", "application/json")
                     .body([transition: [id: transitionID]])
Updated by Kristian Walker

File snippet.groovy Modified

  • Ignore whitespace
  • Hide word diff
 * amended and must be included in any circumstances where the code snippet is shared by You or a third party."
 */
 
-// Variable to store the fix version
-def fixVersion = "<VersionNameHere>"
 
 // Variable to store the issue type to be matched on
 def issueType = "<IssueTypeNameHere>"
 // The ID of the workflow transition to execute
 def transitionID = <TransitionIDHere>
 
+def jqlQuery = "<AddJQLQueryHere>"
+
 // Get all issues matching a specified version in the Development Complete
 def allmatchingIssues = get("/rest/api/2/search")
-        .queryString("jql", "fixVersion = '${fixVersion}'")
-        .queryString("fields", "fixVersion")  // Only return the fix version value field to speed up the search
+        .queryString("jql", jqlQuery)
         .asObject(Map)
         .body
         .issues as List<Map>
Updated by Kristian Walker

File snippet.groovy Added

  • Ignore whitespace
  • Hide word diff
+/*
+* This example script console script transitions issues returned from the JQL search which meet the specified conditions.
+* "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."
+*/
+
+// Variable to store the fix version
+def fixVersion = "<VersionNameHere>"
+
+// Variable to store the issue type to be matched on
+def issueType = "<IssueTypeNameHere>"
+
+// Variable to store the status to match on
+def status = "<StatusNameHere>"
+
+// The ID of the workflow transition to execute
+def transitionID = <TransitionIDHere>
+
+// Get all issues matching a specified version in the Development Complete
+def allmatchingIssues = get("/rest/api/2/search")
+        .queryString("jql", "fixVersion = '${fixVersion}'")
+        .queryString("fields", "fixVersion")  // Only return the fix version value field to speed up the search
+        .asObject(Map)
+        .body
+        .issues as List<Map>
+
+// Log out the number of issues returned by the search
+logger.info("The number of issues returned by the JQL search = : ${allmatchingIssues.size()}")
+
+// Log out the map of issues returned by the search.
+logger.info("The returned issues are " + allmatchingIssues)
+
+// Iterate over each issue returned
+allmatchingIssues.each { it ->
+
+    // Get the issue object for each issue returned within the search
+    def issue = get('/rest/api/2/issue/' + it.key)
+            .header('Content-Type', 'application/json')
+            .asObject(Map)
+
+    // Check if the issue in the issue type is Deployment status
+    if (issue.body.fields.status.name == "${status}") {
+        // check if the issue is of issue type Development Completed if the issuetype = Deployment
+        if (issue.body.fields.issuetype.name == "${issueType}") {
+            // If  all of  the conditions are met transition the issue to the Ready for Testing status
+            def transition = post('/rest/api/2/issue/' + it.key + '/transitions')
+                    .header("Content-Type", "application/json")
+                    .body([transition: [id: transitionID]])
+                    .asObject(Map)
+        }
+    }
+}
+return "Script execution finished"

File snippet.txt Deleted

  • Ignore whitespace
  • Hide word diff
-/*
-* This example script console script transitions issues returned from the JQL search which meet the specified conditions.
-* "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."
-*/
-
-// Variable to store the fix version
-def fixVersion = "<VersionNameHere>"
-
-// Variable to store the issue type to be matched on
-def issueType = "<IssueTypeNameHere>"
-
-// Variable to store the status to match on
-def status = "<StatusNameHere>"
-
-// The ID of the workflow transition to execute
-def transitionID = <TransitionIDHere>
-
-// Get all issues matching a specified version in the Development Complete
-def allmatchingIssues = get("/rest/api/2/search")
-        .queryString("jql", "fixVersion = '${fixVersion}'")
-        .queryString("fields", "fixVersion")  // Only return the fix version value field to speed up the search
-        .asObject(Map)
-        .body
-        .issues as List<Map>
-
-// Log out the number of issues returned by the search
-logger.info("The number of issues returned by the JQL search = : ${allmatchingIssues.size()}")
-
-// Log out the map of issues returned by the search.
-logger.info("The returned issues are " + allmatchingIssues)
-
-// Iterate over each issue returned
-allmatchingIssues.each { it ->
-
-    // Get the issue object for each issue returned within the search
-    def issue = get('/rest/api/2/issue/' + it.key)
-            .header('Content-Type', 'application/json')
-            .asObject(Map)
-
-    // Check if the issue in the issue type is Deployment status
-    if (issue.body.fields.status.name == "${status}") {
-        // check if the issue is of issue type Development Completed if the issuetype = Deployment
-        if (issue.body.fields.issuetype.name == "${issueType}") {
-            // If  all of  the conditions are met transition the issue to the Ready for Testing status
-            def transition = post('/rest/api/2/issue/' + it.key + '/transitions')
-                    .header("Content-Type", "application/json")
-                    .body([transition: [id: transitionID]])
-                    .asObject(Map)
-        }
-    }
-}
-return "Script execution finished"
Updated by Kristian Walker

File snippet.txt Modified

  • Ignore whitespace
  • Hide word diff
 /*
-* This example script console script clears the fix version and affects version field
+* This example script console script transitions issues returned from the JQL search which meet the specified conditions.
 * "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."
Created by Kristian Walker

File snippet.txt Added

  • Ignore whitespace
  • Hide word diff
+/*
+* This example script console script clears the fix version and affects version field
+* "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."
+*/
+
+// Variable to store the fix version
+def fixVersion = "<VersionNameHere>"
+
+// Variable to store the issue type to be matched on
+def issueType = "<IssueTypeNameHere>"
+
+// Variable to store the status to match on
+def status = "<StatusNameHere>"
+
+// The ID of the workflow transition to execute
+def transitionID = <TransitionIDHere>
+
+// Get all issues matching a specified version in the Development Complete
+def allmatchingIssues = get("/rest/api/2/search")
+        .queryString("jql", "fixVersion = '${fixVersion}'")
+        .queryString("fields", "fixVersion")  // Only return the fix version value field to speed up the search
+        .asObject(Map)
+        .body
+        .issues as List<Map>
+
+// Log out the number of issues returned by the search
+logger.info("The number of issues returned by the JQL search = : ${allmatchingIssues.size()}")
+
+// Log out the map of issues returned by the search.
+logger.info("The returned issues are " + allmatchingIssues)
+
+// Iterate over each issue returned
+allmatchingIssues.each { it ->
+
+    // Get the issue object for each issue returned within the search
+    def issue = get('/rest/api/2/issue/' + it.key)
+            .header('Content-Type', 'application/json')
+            .asObject(Map)
+
+    // Check if the issue in the issue type is Deployment status
+    if (issue.body.fields.status.name == "${status}") {
+        // check if the issue is of issue type Development Completed if the issuetype = Deployment
+        if (issue.body.fields.issuetype.name == "${issueType}") {
+            // If  all of  the conditions are met transition the issue to the Ready for Testing status
+            def transition = post('/rest/api/2/issue/' + it.key + '/transitions')
+                    .header("Content-Type", "application/json")
+                    .body([transition: [id: transitionID]])
+                    .asObject(Map)
+        }
+    }
+}
+return "Script execution finished"
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.