Created
June 25, 2025 06:02
-
-
Save vikrantyadav11/a30575aa1c497b42119098a1554ec1b8 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
def eventIssue = Issues.getByKey(issue.key as String) | |
// Construct JQL query | |
def jqlQuery = "issue in linkedIssues(\"${eventIssue.key}\") AND project = \"MTP\"" | |
// Run search using the latest API | |
def searchResult = get("/rest/api/3/search/jql") | |
.queryString("jql", jqlQuery) | |
.queryString("fields", "summary,key,status") | |
.queryString("maxResults", "50") // adjust as needed | |
.asObject(Map) | |
if (searchResult.status == 200) { | |
def issues = searchResult.body.issues | |
issues.each { i -> | |
def issueKey = i.key | |
def statusName = i.fields.status.name | |
logger.info("Issue ${issueKey} has status: ${statusName}") | |
if (statusName == "Backlog") { | |
// Direct transition using known ID 21 | |
def transitionResult = post("/rest/api/3/issue/${issueKey}/transitions") | |
.header("Content-Type", "application/json") | |
.body([ | |
transition: [id: 21] | |
]) | |
.asString() | |
if (transitionResult.status == 204) { | |
logger.info("Successfully moved ${issueKey} to 'In Progress'.") | |
} else { | |
logger.error("Failed to transition ${issueKey}: HTTP ${transitionResult.status}") | |
} | |
} | |
} | |
} else { | |
logger.error("Failed to run JQL: ${searchResult.status} - ${searchResult.body}") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment