Open sani-d opened 3 weeks ago
def issueKey = issue.key
def commentText1 = """ (/) Please make sure the toggle is documented on this page: https://tideaccount.atlassian.net/wiki/spaces/PS/pages/1216807030/Tide+Feature+Toggles (/) Please note that support in production requires a handover!
(!) Did you inform MS about this upcoming production rollout? (!) lvl2 MS for your area should be informed first! """
// Step 2: Get existing comments for the issue def commentsResult = get('/rest/api/2/issue/' + issueKey + '/comment') .header('Content-Type', 'application/json') .asObject(Map)
// Step 3: Check for duplicate comments def comments = commentsResult.body.comments def commentAlreadyExists = comments.any { comment -> comment.body.contains(commentText1.trim()) }
def requestType = issue.fields.customfield_10848?.requestType?.name println(requestType) if (requestType == "Update feature toggles") { if (!commentAlreadyExists) { // Step 4: Add the new comment only if it doesn't already exist def addCommentResult = post('/rest/api/2/issue/' + issueKey + '/comment') .header('Content-Type', 'application/json') .body(["body": commentText1.trim()]) .asObject(Map)
println("Comment added. Response: ${addCommentResult}")
} else { println("Duplicate comment found, not adding a new one.") } } else { println("Request type is not 'Update feature toggles', skipping automated comments.") }
def issueKey = issue.key
def commentText1 = """ (/) Please make sure the toggle is documented on this page: https://tideaccount.atlassian.net/wiki/spaces/PS/pages/1216807030/Tide+Feature+Toggles (/) Please note that support in production requires a handover!
(!) Did you inform MS about this upcoming production rollout? (!) lvl2 MS for your area should be informed first! """
// Step 2: Get existing comments for the issue def commentsResult = get('/rest/api/2/issue/' + issueKey + '/comment') .header('Content-Type', 'application/json') .asObject(Map)
// Step 3: Check for duplicate comments def comments = commentsResult.body.comments def commentAlreadyExists = comments.any { comment -> comment.body.contains(commentText1.trim()) }
def requestType = issue.fields.customfield_10848?.requestType?.name println(requestType) if (requestType == "Update feature toggles") { if (!commentAlreadyExists) { // Step 4: Add the new comment only if it doesn't already exist def addCommentResult = post('/rest/api/2/issue/' + issueKey + '/comment') .header('Content-Type', 'application/json') .body(["body": commentText1.trim()]) .asObject(Map)
} else { println("Duplicate comment found, not adding a new one.") } } else { println("Request type is not 'Update feature toggles', skipping automated comments.") }