Bhavya-org / Scripts

0 stars 0 forks source link

send slack when issue transitioned #47

Open Bhavya-ss opened 1 week ago

Bhavya-ss commented 1 week ago

def issueKey = issue.key

def toStatusArray = ["In Progress"]

for (item in changelog.items) { logger.info(item.field) if ( item.field == "status" ) { if ( (toStatusArray.contains(item.toString)) ) { def jiraResult = get("/rest/api/2/issue/${issueKey}") .header('Content-Type', 'application/json') .asObject(Map)

if (jiraResult.status == 200) {
    def jiraFields = jiraResult.body.fields
    def webhookUrl = 'https://hooks.slack.com/services/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'

    def msg = [
        text: """ The following issue has been transitioned to Confirmed

https://tideaccount.atlassian.net/${issue.key}""" ]

    post(webhookUrl)
        .header('Content-Type', 'application/json')
        .body(msg)
        .asString()
} else {
    println "Failed to find issue: Status: ${jiraResult.status} ${jiraResult.body}"
}

} } }

sani-d commented 1 week ago

?// Used in Postfunction for Send slack message when issue transitioned to Confirmed

def issueKey = issue.key def jiraResult = get("/rest/api/2/issue/${issueKey}") .header('Content-Type', 'application/json') .asObject(Map)

if (jiraResult.status == 200){ def jiraFields = jiraResult.body.fields def webhookUrl = 'https://hooks.slack.com/services/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'

def msg = [
    text: "The following issue has been transitioned to Confirmed https://tideaccount.atlassian.net/browse/${issueKey}"
]

post(webhookUrl)
    .header('Content-Type', 'application/json')
    .body(msg)
    .asString()

} else { println "Failed to find issue: Status: ${jiraResult.status} ${jiraResult.body}" }