Open pramodhm112 opened 4 weeks ago
import groovy.json.JsonSlurper
def sourceProjectKey = "ISSD" def targetProjectKey = "LSD" def issueKey = issue.key
// Check if the issue is in the source project if (issue.fields.project.key == sourceProjectKey) { def summary = issue.fields.summary def description = issue.fields.description def reporter = issue.fields.reporter def changeType = issue.fields.customfield_10005 def requestType = issue.fields.customfield_10010?.requestType?.name // Corrected reference def doesTheIncident = issue.fields.customfield_11976?.value // Corrected reference def customfield_12039Value = issue.fields.customfield_12039 def customfield_12040Value = issue.fields.customfield_12040 def customfield_11981Value = issue.fields.customfield_11981 def customfield_12034Value = issue.fields.customfield_12034 def customfield_12041Value = issue.fields.customfield_12041 def customfield_12038Value = issue.fields.customfield_12038 def customfield_12042Value = issue.fields.customfield_12042 def customfield_12043Value = issue.fields.customfield_12043
// Check if the request type is "Live or suspected security incident" and incident is "Yes" if (requestType == "Live or suspected security incident" && doesTheIncident == "Yes") { def newSecurityLevelId = '10008' // Provide the ID of the new security level def securityLevelUpdateResult = put("/rest/api/3/issue/${issueKey}") .header('Content-Type', 'application/json') .body([ fields: [ security: [ id: newSecurityLevelId ] ] ]) .asString() def targetIssueTypeId = 10767 if (targetIssueTypeId) { def createIssuePayload = [ fields: [ project: [ key: targetProjectKey ], summary: summary, description: description, reporter: reporter, customfield_12039: customfield_12039Value, customfield_12040: customfield_12040Value, customfield_11981: customfield_11981Value, customfield_12034: customfield_12034Value, customfield_12041: customfield_12041Value, customfield_12038: customfield_12038Value, customfield_12042: customfield_12042Value, customfield_12043: customfield_12043Value, issuetype: [ id: targetIssueTypeId ] ] ] def createResult = post("/rest/api/2/issue") .header('Content-Type', 'application/json') .body(createIssuePayload) .asObject(Map) if (createResult.status == 201) { def newIssueKey = createResult.body.key def linkResult = post("/rest/api/2/issueLink") .header('Content-Type', 'application/json') .body([ type: [ name: "Problem/Incident" ], inwardIssue: [ key: issueKey ], outwardIssue: [ key: newIssueKey ] ]) .asObject(Map) if (linkResult.status == 201) { println "Issue ${newIssueKey} created and linked to ${issueKey} successfully." } else { println "Failed to link issue ${newIssueKey} to ${issueKey}: ${linkResult.body}" } } else { println "Failed to create issue in ${targetProjectKey}: ${createResult.status}" println "Response body: ${createResult.body}" } } } else { println "Issue ${issueKey} does not meet the criteria for request type and incident." }
} else { println "Issue ${issueKey} is not in the source project ${sourceProjectKey}." }
🚨 Live or suspected security incident
import groovy.json.JsonSlurper
def sourceProjectKey = "ISSD" def targetProjectKey = "LSD" def issueKey = issue.key
// Check if the issue is in the source project if (issue.fields.project.key == sourceProjectKey) { def summary = issue.fields.summary def description = issue.fields.description def reporter = issue.fields.reporter def changeType = issue.fields.customfield_10005 def requestType = issue.fields.customfield_10010?.requestType?.name // Corrected reference def doesTheIncident = issue.fields.customfield_11976?.value // Corrected reference def customfield_12039Value = issue.fields.customfield_12039 def customfield_12040Value = issue.fields.customfield_12040 def customfield_11981Value = issue.fields.customfield_11981 def customfield_12034Value = issue.fields.customfield_12034 def customfield_12041Value = issue.fields.customfield_12041 def customfield_12038Value = issue.fields.customfield_12038 def customfield_12042Value = issue.fields.customfield_12042 def customfield_12043Value = issue.fields.customfield_12043
} else { println "Issue ${issueKey} is not in the source project ${sourceProjectKey}." }