2020-01-17 12:07:01 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
|
|
|
pipeline {
|
2020-01-21 08:01:05 +00:00
|
|
|
agent any
|
2020-01-17 12:07:01 +00:00
|
|
|
environment {
|
|
|
|
PROJECT_NAME = 'hedera-web'
|
|
|
|
}
|
|
|
|
stages {
|
|
|
|
stage('Checkout') {
|
|
|
|
steps {
|
2022-05-05 09:05:05 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2021-04-29 22:20:36 +00:00
|
|
|
setEnv()
|
2020-01-17 12:07:01 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-21 08:00:03 +00:00
|
|
|
stage('Package') {
|
2020-01-17 12:07:01 +00:00
|
|
|
when {
|
|
|
|
branch 'master'
|
2022-05-05 09:05:05 +00:00
|
|
|
branch 'test'
|
2020-01-17 12:07:01 +00:00
|
|
|
}
|
2020-01-21 08:00:03 +00:00
|
|
|
agent {
|
|
|
|
docker {
|
|
|
|
image 'registry.verdnatura.es/vn-debuild'
|
|
|
|
registryUrl 'https://registry.verdnatura.es/'
|
|
|
|
registryCredentialsId 'docker-registry'
|
2021-09-27 12:34:15 +00:00
|
|
|
args '-v /mnt/appdata/reprepro:/reprepro'
|
2020-01-21 08:00:03 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-17 12:07:01 +00:00
|
|
|
steps {
|
|
|
|
sh 'debuild -us -uc -b'
|
|
|
|
sh 'vn-includedeb'
|
|
|
|
}
|
|
|
|
}
|
2020-01-21 08:00:03 +00:00
|
|
|
stage('Build') {
|
|
|
|
when {
|
|
|
|
branch 'master'
|
2022-05-05 09:05:05 +00:00
|
|
|
branch 'test'
|
2020-01-21 08:00:03 +00:00
|
|
|
}
|
|
|
|
environment {
|
|
|
|
CREDS = credentials('docker-registry')
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY'
|
2020-01-21 08:56:35 +00:00
|
|
|
sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel'
|
2020-01-21 08:00:03 +00:00
|
|
|
sh 'docker-compose push'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Deploy') {
|
|
|
|
when {
|
|
|
|
branch 'master'
|
2022-05-05 09:05:05 +00:00
|
|
|
branch 'test'
|
2020-01-21 08:00:03 +00:00
|
|
|
}
|
2021-04-29 22:07:06 +00:00
|
|
|
environment {
|
|
|
|
DOCKER_HOST = "${env.SWARM_HOST}"
|
|
|
|
}
|
2020-01-21 08:00:03 +00:00
|
|
|
steps {
|
2021-04-29 22:07:06 +00:00
|
|
|
dockerStackDeploy()
|
2020-01-21 08:00:03 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-17 12:07:01 +00:00
|
|
|
}
|
|
|
|
post {
|
2022-05-05 09:05:05 +00:00
|
|
|
unsuccessful {
|
2021-04-29 22:20:36 +00:00
|
|
|
sendEmail()
|
2020-01-17 12:07:01 +00:00
|
|
|
}
|
|
|
|
}
|
2022-05-05 09:05:05 +00:00
|
|
|
}
|