-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathclean-deployments.groovy
More file actions
31 lines (29 loc) · 1.16 KB
/
clean-deployments.groovy
File metadata and controls
31 lines (29 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
node('quickstart-template') {
try {
properties([
pipelineTriggers([cron('@daily')]),
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '14', numToKeepStr: ''))
])
checkout scm
stage('Delete deployments') {
def script_path = 'scripts/clean-deployments.sh'
sh 'sudo chmod +x ' + script_path
withCredentials([usernamePassword(credentialsId: 'AzDevOpsTestingSP', passwordVariable: 'app_key', usernameVariable: 'app_id')]) {
sh script_path + ' -ai ' + env.app_id + ' -ak ' + env.app_key
}
}
} catch (e) {
def public_build_url = "$BUILD_URL".replaceAll("10.0.0.4:8080" , "devops-ci.westcentralus.cloudapp.azure.com")
withCredentials([string(credentialsId: 'TeamEmailAddress', variable: 'email_address')]) {
emailext (
attachLog: true,
subject: "Jenkins Job '$JOB_NAME' #$BUILD_NUMBER Failed",
body: public_build_url,
to: env.email_address
)
}
throw e
} finally {
sh 'az logout'
}
}