if (requestType == "Fix an account problem" && !["63176aa38d88ec800fbf9b17", "630a0d15ec02b5f28b63a024"].contains(reporter)) {
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.")
}
def selectListFieldId = 'customfield_10005' // Replace 'customfield_10075' with your field ID
def result = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
(selectListFieldId): [value: "Normal"] as Map
]
])
.asString()
def transition = post("/rest/api/2/issue/${issueKey}/transitions")
.header("Content-Type", "application/json")
.body([transition: [id: 11]])
.asObject(Map)
} else {
println("Condition not met' , skipping the actions.")
}
def issueKey = issue.key def requestType = issue.fields.customfield_10010?.requestType?.name println(requestType) def reporter = issue.fields.reporter?.accountId
def commentText1 = """ @james Garrington please add the requestor to the communication exclusion list https://docs.google.com/spreadsheets/d/1ai1MxigfSoGzAJWH7tV9hxCjiaJ1Esn0vRBKybrpJTk/edit#gid=0 """
// 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()) }
if (requestType == "Fix an account problem" && !["63176aa38d88ec800fbf9b17", "630a0d15ec02b5f28b63a024"].contains(reporter)) { 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("Condition not met' , skipping the actions.") }