-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
43 lines (37 loc) · 1.3 KB
/
Jenkinsfile
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
32
33
34
35
36
37
38
39
40
41
42
43
timeout(time: 20, uint: 'MINUTES') {
node {
properties([buildDiscarder(logRotator(numToKeepStr: "10"))])
deleteDir()
stage("Checkout") {
checkout scm
}
try {
nvm(version: "8") {
stage("Build") {
sh "./deployment/build.sh"
archiveArtifacts artifacts: "*.tar.gz", fingerprint: true
}
def isDeployingProd = env.BRANCH_NAME == "master"
if (isDeployingProd) {
withCredentials([sshUserPrivateKey(
credentialsId: "4041a521-7700-4cac-9df5-b4001f739975",
keyFileVariable: "GITHUB_KEY"
)]) {
stage("Deploy") {
sh "ansible-playbook ./deployment/site.yml -i ./deployment/hosts --extra-vars \"payments_version=${env.BUILD_NUMBER}\" --key-file $GITHUB_KEY"
}
}
}
}
} catch (err) {
currentBuild.result = 'FAIL'
emailext (
subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]': Check console output at '${env.BUILD_URL}' [${env.BUILD_NUMBER}]",
recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']],
to: "[email protected]"
)
throw err
}
}
}