salix/Jenkinsfile

65 lines
1.8 KiB
Plaintext
Raw Normal View History

2017-05-12 10:41:35 +00:00
#!/usr/bin/env groovy
2018-04-06 16:14:49 +00:00
node {
2018-10-24 12:41:38 +00:00
stage ('Checkout') {
checkout scm
}
stage ('Install Node dependencies') {
2018-10-25 10:16:55 +00:00
nodejs('node-lts') {
2019-01-07 07:56:11 +00:00
sh "NODE_ENV="" npm install --no-audit"
2018-10-24 12:41:38 +00:00
sh "gulp install"
2018-10-24 12:10:41 +00:00
}
2018-10-24 12:41:38 +00:00
}
stage ('Build project') {
2018-10-25 10:16:55 +00:00
nodejs('node-lts') {
2018-10-24 12:41:38 +00:00
sh "gulp build"
2018-10-24 12:10:41 +00:00
}
2018-10-25 08:51:47 +00:00
}
2019-01-01 22:43:00 +00:00
stage ('Docker deployment') {
2019-01-01 23:40:53 +00:00
withCredentials([dockerCert(credentialsId: 'docker', variable: 'DOCKER_CERT_PATH')]) {
2019-01-02 00:16:28 +00:00
if (env.BRANCH_NAME != 'master') {
2019-01-07 08:54:00 +00:00
env.COMPOSE_PROJECT_NAME = "${env.BRANCH_NAME}-${env.JOB_NAME}"
}
switch (env.BRANCH_NAME) {
case 'master':
env.NODE_ENV = 'production'
break;
case 'test':
env.NODE_ENV = 'test'
break;
case 'dev':
env.NODE_ENV = 'development'
break;
2019-01-02 00:16:28 +00:00
}
2019-01-02 01:02:29 +00:00
switch (env.BRANCH_NAME) {
case 'master':
env.PORT = 5000
break;
case 'test':
env.PORT = 5001
break;
}
2019-01-07 08:54:00 +00:00
env.COMPOSE_PROJECT_NAME = env.JOB_NAME
env.DOCKER_TLS_VERIFY = 1
env.TAG = env.NODE_ENV
2019-01-02 01:02:29 +00:00
env.DOCKER_HOST = 'tcp://vch1.verdnatura.es:2376';
sh "docker-compose up --build -d"
2019-01-01 22:43:00 +00:00
env.DOCKER_HOST = 'tcp://vch2.verdnatura.es:2376';
2019-01-02 00:25:49 +00:00
sh "docker-compose up --build -d"
2019-01-01 22:43:00 +00:00
}
2018-10-24 12:41:38 +00:00
}
2018-01-08 10:07:52 +00:00
}
2019-01-07 08:54:00 +00:00
post {
always {
mail to: 'salix@verdnatura.es', subject: 'Pipeline', "Pipeline success: ${env.JOB_NAME}"
}
failure {
mail to: 'salix@verdnatura.es', subject: 'Pipeline', "Pipeline failed: ${env.JOB_NAME}"
}
}