Skip to content

Instantly share code, notes, and snippets.

@dfrancolr
Last active August 21, 2020 14:25
Show Gist options
  • Save dfrancolr/07df6f4a1a06e1d0e14c39e6de55c5b4 to your computer and use it in GitHub Desktop.
Save dfrancolr/07df6f4a1a06e1d0e14c39e6de55c5b4 to your computer and use it in GitHub Desktop.
def call() {
if (env.CHANGE_BRANCH && env.BUILD_NUMBER == "1" && env.BRANCH_NAME.contains('PR')) {
try {
withCredentials([string(credentialsId: 'jira-token', variable: 'JIRA_TOKEN')]) {
sh """ curl -s -X POST https://${env.JIRA_URL}/rest/api/2/issue/${env.CHANGE_BRANCH}/comment -H 'Authorization: Basic ${JIRA_TOKEN}' -H 'Content-Type: application/json' -d '{ "body": "PR - ${env.CHANGE_URL} "}' """
}
} catch (err) {
println("Can't update Task on Jira")
}
} else {
println("Can't update Task on Jira")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment