2022-11-16 11:58:03 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
environment {
|
|
|
|
PROJECT_NAME = 'printnatura'
|
2024-05-22 07:59:01 +00:00
|
|
|
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
|
2022-11-16 11:58:03 +00:00
|
|
|
}
|
|
|
|
stages {
|
|
|
|
stage('Checkout') {
|
|
|
|
steps {
|
2024-05-22 07:59:01 +00:00
|
|
|
script {
|
|
|
|
def packageJson = readJSON file: 'package.json'
|
|
|
|
env.VERSION = packageJson.version
|
|
|
|
}
|
2022-11-16 11:58:03 +00:00
|
|
|
setEnv()
|
|
|
|
}
|
|
|
|
}
|
2024-05-22 07:59:01 +00:00
|
|
|
stage('Build') {
|
|
|
|
when {branch 'master'}
|
2022-11-16 11:58:03 +00:00
|
|
|
environment {
|
2024-05-22 07:59:01 +00:00
|
|
|
IMAGE = 'registry.verdnatura.es/printnatura'
|
|
|
|
TAG = "${env.VERSION}"
|
|
|
|
CREDENTIALS = credentials('docker-registry')
|
2022-11-16 11:58:03 +00:00
|
|
|
}
|
|
|
|
steps {
|
2024-05-22 07:59:01 +00:00
|
|
|
sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY'
|
2022-11-16 11:58:03 +00:00
|
|
|
sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel'
|
|
|
|
sh 'docker-compose push'
|
2024-05-22 07:59:01 +00:00
|
|
|
|
|
|
|
sh 'docker tag $IMAGE:$TAG $IMAGE:latest'
|
|
|
|
sh 'docker push $IMAGE:latest'
|
2022-11-16 11:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
post {
|
|
|
|
unsuccessful {
|
|
|
|
sendEmail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|