Skip to content

Commit

Permalink
Merge pull request project-sunbird#793 from project-sunbird/kp-patch
Browse files Browse the repository at this point in the history
feat: Adding slack and email notify code
  • Loading branch information
rjshrjndrn authored Sep 3, 2019
2 parents 8a2b524 + f00f699 commit 4206b87
Show file tree
Hide file tree
Showing 94 changed files with 696 additions and 459 deletions.
19 changes: 7 additions & 12 deletions pipelines/backup/cassandra-backup/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,17 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
currentBuild.result = 'SUCCESS'
}
catch (err) {
currentBuild.result = 'FAILURE'
slackSend (
channel: "${env.NOTIFY_SLACK_CHANNEL}",
color: 'danger',
message: "Build Failed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
)
currentBuild.result = "FAILURE"
throw err
} finally {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: "${env.NOTIFY_EMAIL_ADDRESS}",
sendToIndividuals: true])
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
19 changes: 7 additions & 12 deletions pipelines/backup/es-backup/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,17 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
currentBuild.result = 'SUCCESS'
}
catch (err) {
currentBuild.result = 'FAILURE'
slackSend (
channel: "${env.NOTIFY_SLACK_CHANNEL}",
color: 'danger',
message: "Build Failed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
)
currentBuild.result = "FAILURE"
throw err
} finally {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: "${env.NOTIFY_EMAIL_ADDRESS}",
sendToIndividuals: true])
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
6 changes: 6 additions & 0 deletions pipelines/backup/es-restore/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
}
catch (err) {
currentBuild.result = "FAILURE"
throw err
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
19 changes: 7 additions & 12 deletions pipelines/backup/grafana-backup/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,17 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
currentBuild.result = 'SUCCESS'
}
catch (err) {
currentBuild.result = 'FAILURE'
slackSend (
channel: "${env.NOTIFY_SLACK_CHANNEL}",
color: 'danger',
message: "Build Failed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
)
currentBuild.result = "FAILURE"
throw err
} finally {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: "${env.NOTIFY_EMAIL_ADDRESS}",
sendToIndividuals: true])
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
19 changes: 7 additions & 12 deletions pipelines/backup/jenkins-backup-upload/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,17 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
currentBuild.result = 'SUCCESS'
}
catch (err) {
currentBuild.result = 'FAILURE'
slackSend (
channel: "${env.NOTIFY_SLACK_CHANNEL}",
color: 'danger',
message: "Build Failed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
)
currentBuild.result = "FAILURE"
throw err
} finally {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: "${env.NOTIFY_EMAIL_ADDRESS}",
sendToIndividuals: true])
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
19 changes: 7 additions & 12 deletions pipelines/backup/jenkins-backup/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,17 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
currentBuild.result = 'SUCCESS'
}
catch (err) {
currentBuild.result = 'FAILURE'
slackSend (
channel: "${env.NOTIFY_SLACK_CHANNEL}",
color: 'danger',
message: "Build Failed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
)
currentBuild.result = "FAILURE"
throw err
} finally {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: "${env.NOTIFY_EMAIL_ADDRESS}",
sendToIndividuals: true])
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
19 changes: 7 additions & 12 deletions pipelines/backup/logger-es-backup/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,17 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
currentBuild.result = 'SUCCESS'
}
catch (err) {
currentBuild.result = 'FAILURE'
slackSend (
channel: "${env.NOTIFY_SLACK_CHANNEL}",
color: 'danger',
message: "Build Failed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
)
currentBuild.result = "FAILURE"
throw err
} finally {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: "${env.NOTIFY_EMAIL_ADDRESS}",
sendToIndividuals: true])
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
6 changes: 6 additions & 0 deletions pipelines/backup/logger-es-restore/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
}
catch (err) {
currentBuild.result = "FAILURE"
throw err
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
6 changes: 6 additions & 0 deletions pipelines/backup/managed-postgres-backup/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
}
catch (err) {
currentBuild.result = "FAILURE"
throw err
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
19 changes: 7 additions & 12 deletions pipelines/backup/postgresql-backup/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,17 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
currentBuild.result = 'SUCCESS'
}
catch (err) {
currentBuild.result = 'FAILURE'
slackSend (
channel: "${env.NOTIFY_SLACK_CHANNEL}",
color: 'danger',
message: "Build Failed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
)
currentBuild.result = "FAILURE"
throw err
} finally {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: "${env.NOTIFY_EMAIL_ADDRESS}",
sendToIndividuals: true])
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
7 changes: 7 additions & 0 deletions pipelines/backup/postgresql-restore/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
}
catch (err) {
currentBuild.result = 'FAILURE'
throw err
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
19 changes: 7 additions & 12 deletions pipelines/backup/prometheus-backup/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,17 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
currentBuild.result = 'SUCCESS'
}
catch (err) {
currentBuild.result = 'FAILURE'
slackSend (
channel: "${env.NOTIFY_SLACK_CHANNEL}",
color: 'danger',
message: "Build Failed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
)
currentBuild.result = "FAILURE"
throw err
} finally {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: "${env.NOTIFY_EMAIL_ADDRESS}",
sendToIndividuals: true])
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
19 changes: 6 additions & 13 deletions pipelines/backup/prometheus-fed-stateful-backup/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,16 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)

currentBuild.result = 'SUCCESS'
}
}
currentBuild.result = 'SUCCESS'
}
catch (err) {
currentBuild.result = 'FAILURE'
slackSend (
channel: "${env.NOTIFY_SLACK_CHANNEL}",
color: 'danger',
message: "Build Failed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
)
currentBuild.result = "FAILURE"
throw err
} finally {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: "${env.NOTIFY_EMAIL_ADDRESS}",
sendToIndividuals: true])
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
10 changes: 7 additions & 3 deletions pipelines/backup/prometheus-restore/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ node() {
module = sh(returnStdout: true, script: "echo $JOB_NAME").split('/')[-2].trim()
jobName = sh(returnStdout: true, script: "echo $JOB_NAME").split('/')[-1].trim()
currentWs = sh(returnStdout: true, script: 'pwd').trim()

ansiblePlaybook = "${currentWs}/ansible/prometheus-restore.yml"
ansibleExtraArgs = "--tags ${params.tag} --extra-vars \"prometheus_hosts=${params.prometheus_hosts} manager_host=${params.manager_host}\" --vault-password-file /var/lib/jenkins/secrets/vault-pass"
values.put('currentWs', currentWs)
Expand All @@ -30,11 +29,16 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)

}
currentBuild.result = 'SUCCESS'
}
}
}
catch (err) {
currentBuild.result = 'FAILURE'
throw err
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
7 changes: 7 additions & 0 deletions pipelines/bootstrap-swarm/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@ node() {
values.put('ansibleExtraArgs', ansibleExtraArgs)
println values
ansible_playbook_run(values)
currentBuild.result = 'SUCCESS'
currentBuild.description = "Private: ${params.private_branch}, Public: ${params.branch_or_tag}"
}
}
}
catch (err) {
currentBuild.result = 'FAILURE'
throw err
}
finally {
slack_notify(currentBuild.result)
email_notify()
}
}
Loading

0 comments on commit 4206b87

Please sign in to comment.