hedera-web/Jenkinsfile

98 lines
2.6 KiB
Plaintext
Raw Normal View History

2020-01-17 12:07:01 +00:00
#!/usr/bin/env groovy
2024-02-22 08:25:38 +00:00
def BRANCH_ENV = [
test: 'test',
master: 'production'
]
node {
stage('Setup') {
env.MAIN_REPLICAS = 1
env.CRON_REPLICAS = 0
env.NODE_ENV = BRANCH_ENV[env.BRANCH_NAME] ?: 'dev'
switch (env.BRANCH_NAME) {
case 'master':
env.MAIN_REPLICAS = 3
env.CRON_REPLICAS = 1
break
}
echo "NODE_NAME: ${env.NODE_NAME}"
echo "WORKSPACE: ${env.WORKSPACE}"
}
}
2020-01-17 12:07:01 +00:00
pipeline {
2020-01-21 08:01:05 +00:00
agent any
2020-01-17 12:07:01 +00:00
environment {
PROJECT_NAME = 'hedera-web'
2022-05-05 09:39:49 +00:00
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
2020-01-17 12:07:01 +00:00
}
stages {
2022-10-10 11:22:17 +00:00
stage('Debuild') {
2020-01-17 12:07:01 +00:00
when {
2022-05-05 09:19:29 +00:00
anyOf {
branch 'master'
branch 'test'
}
2020-01-17 12:07:01 +00:00
}
2020-01-21 08:00:03 +00:00
agent {
docker {
image 'registry.verdnatura.es/debuild:2.23.4-vn1'
2020-01-21 08:00:03 +00:00
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'
2023-06-20 14:56:19 +00:00
sh 'vn-includedeb bookworm'
2020-01-17 12:07:01 +00:00
}
}
2022-10-10 11:22:17 +00:00
stage('Container') {
2020-01-21 08:00:03 +00:00
when {
2022-05-05 09:19:29 +00:00
anyOf {
branch 'master'
branch 'test'
}
2020-01-21 08:00:03 +00:00
}
environment {
CREDS = credentials('docker-registry')
}
steps {
2024-02-22 08:25:38 +00:00
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
}
2020-01-21 08:00:03 +00:00
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 {
2022-05-05 09:19:29 +00:00
anyOf {
branch 'master'
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 {
2024-02-22 08:25:38 +00:00
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
}
2022-05-05 09:39:49 +00:00
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
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 {
2024-02-22 08:25:38 +00:00
setEnv()
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
}