Skip to content

Instantly share code, notes, and snippets.

@PrashantBhatasana
Created November 14, 2019 10:41
Show Gist options
  • Save PrashantBhatasana/a4e94a398dd6701baf5beb6eef47367e to your computer and use it in GitHub Desktop.
Save PrashantBhatasana/a4e94a398dd6701baf5beb6eef47367e to your computer and use it in GitHub Desktop.
This is Demo Jenkinsfile for Slack integration.
def err = null
try {
node {
stage('Start Notification') {
slackSend baseUrl: 'https://prashant-bhatasana.slack.com/services/hooks/jenkins-ci/', channel: '#test_notification', color: 'Green', failOnError: true, message: " Android build pipeline - '${env.BUILD_NUMBER}' -- $STAGE ", teamDomain: 'https://prashant-bhatasana.slack.com', tokenCredentialId: '7ca00656-3323-7789-9b1a-e2c836b9a73f'
}
<<<<<<<<<<<<<<<<< Add your Pipeline Script here >>>>>>>>>>>>>>>>>
}
} catch (caughtError) {
err = caughtError
currentBuild.result = "FAILURE"
} finally {
if(currentBuild.result == "FAILURE"){
slackSend(color: '#FF0000', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}] -- $STAGE' (${env.BUILD_URL})")
}else{
slackSend(color: '#58b368', message: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}] -- $STAGE' (${env.BUILD_URL}) (${BUILD_URL}artifact/android/app/build/outputs/apk/release/app-release.apk)")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment