-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
51 lines (48 loc) · 1.34 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
44
45
46
47
48
49
50
51
pipeline {
environment {
CRED = credentials("aquagis_www")
}
agent {
node {
label 'docker'
}
}
stages {
stage('Building') {
steps {
script {
shortCommit = sh(returnStdout: true, script: "git log -n 1 --pretty=format:'%h'").trim()
}
echo "Building aquagis/${shortCommit}"
}
}
stage("Deploy") {
when {
anyOf {
branch 'master';
branch 'staging';
}
}
steps {
script {
if (env.BRANCH_NAME == 'master') {
DEPLOY_TO = "prod"
} else if (env.BRANCH_NAME == 'staging') {
DEPLOY_TO = "staging"
}
}
sh "docker build --build-arg ENV=${DEPLOY_TO} --build-arg VERSION=95580a1 -f deploy/www/Dockerfile -t geographica/aquagis_www:${DEPLOY_TO} ."
sh "docker run --rm --name aquagis_www_${DEPLOY_TO} -e \"S3_WEBSITE_ID=${CRED_USR}\" -e \"S3_WEBSITE_SECRET=${CRED_PSW}\" geographica/aquagis_www:${DEPLOY_TO} npm run-script deploy"
}
post {
failure {
echo "Pipeline is done"
// notify users when the Pipeline fails
mail to: '[email protected]',
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
body: "Something is wrong with ${env.BUILD_URL}"
}
}
}
}
}