Open Bhavya-ss opened 5 months ago
def issueKey = issue.key def transitionId = 21
// Retrieve the issue def issueResult = get("/rest/api/2/issue/${issueKey}") .header('Content-Type', 'application/json') .asObject(Map)
if (issueResult.status != 200) { logger.warn("Failed to find issue: Status: ${issueResult.status} ${issueResult.body}") }
def parentKey = issueResult.body.fields?.parent?.key
if (!parentKey) { logger.warn("Parent issue not found for ${issueKey}") }
// Retrieve all child issues def childIssuesResult = get("/rest/api/2/search") .queryString("jql", "parent=${parentKey}") .asObject(Map)
assert childIssuesResult.status >= 200 && childIssuesResult.status <= 300
def childIssues = childIssuesResult.body.issues as List
// Check if all child issues are "In Progress" def allInProgress = childIssues.every { child -> def childResult = get("/rest/api/2/issue/${child.key}") .header('Content-Type', 'application/json') .asObject(Map)
if (childResult.status == 200) { return childResult.body.fields.status.name == "In Progress" } else { return false }
}
if (allInProgress) { // Transition the parent issue def transition = post("/rest/api/2/issue/${parentKey}/transitions") .header("Content-Type", "application/json") .body([transition: [id: transitionId]]) .asObject(Map) } else { logger.warn("Not all child issues are in progress.") }
def issueKey = issue.key def transitionId = 21
// Retrieve the issue def issueResult = get("/rest/api/2/issue/${issueKey}") .header('Content-Type', 'application/json') .asObject(Map)
if (issueResult.status != 200) { logger.warn("Failed to find issue: Status: ${issueResult.status} ${issueResult.body}") }
def parentKey = issueResult.body.fields?.parent?.key
if (!parentKey) { logger.warn("Parent issue not found for ${issueKey}") }
// Retrieve all child issues def childIssuesResult = get("/rest/api/2/search") .queryString("jql", "parent=${parentKey}") .asObject(Map)
assert childIssuesResult.status >= 200 && childIssuesResult.status <= 300
def childIssues = childIssuesResult.body.issues as List
// Check if all child issues are "In Progress" def allInProgress = childIssues.every { child -> def childResult = get("/rest/api/2/issue/${child.key}") .header('Content-Type', 'application/json') .asObject(Map)
}
if (allInProgress) { // Transition the parent issue def transition = post("/rest/api/2/issue/${parentKey}/transitions") .header("Content-Type", "application/json") .body([transition: [id: transitionId]]) .asObject(Map) } else { logger.warn("Not all child issues are in progress.") }