0
1
Fork 0
hedera-web-mindshore/Jenkinsfile

87 lines
2.4 KiB
Groovy

#!/usr/bin/env groovy
pipeline {
agent any
environment {
PROJECT_NAME = 'hedera-web'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
}
stages {
stage('Checkout') {
steps {
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
switch (env.BRANCH_NAME) {
case 'master':
env.NODE_ENV = 'production'
env.REPLICAS = 3
break
case 'test':
env.NODE_ENV = 'test'
env.REPLICAS = 1
break
}
}
setEnv()
}
}
stage('Package') {
when {
anyOf {
branch 'master'
branch 'test'
}
}
agent {
docker {
image 'registry.verdnatura.es/vn-debuild'
registryUrl 'https://registry.verdnatura.es/'
registryCredentialsId 'docker-registry'
args '-v /mnt/appdata/reprepro:/reprepro'
}
}
steps {
sh 'debuild -us -uc -b'
sh 'vn-includedeb'
}
}
stage('Build') {
when {
anyOf {
branch 'master'
branch 'test'
}
}
environment {
CREDS = credentials('docker-registry')
}
steps {
sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY'
sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel'
sh 'docker-compose push'
}
}
stage('Deploy') {
when {
anyOf {
branch 'master'
branch 'test'
}
}
environment {
DOCKER_HOST = "${env.SWARM_HOST}"
}
steps {
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
}
}
}
post {
unsuccessful {
sendEmail()
}
}
}