2023-04-08 13:08:37 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
options {
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
}
|
|
|
|
environment {
|
2023-04-10 09:03:26 +00:00
|
|
|
PROJECT_NAME = 'mylogger'
|
2023-04-08 13:08:37 +00:00
|
|
|
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
|
|
|
|
}
|
|
|
|
stages {
|
|
|
|
stage('Checkout') {
|
|
|
|
steps {
|
|
|
|
script {
|
|
|
|
def packageJson = readJSON file: 'package.json'
|
|
|
|
env.VERSION = packageJson.version
|
|
|
|
}
|
|
|
|
setEnv()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Build') {
|
|
|
|
when {branch 'master'}
|
|
|
|
environment {
|
2023-04-11 11:36:57 +00:00
|
|
|
IMAGE = 'registry.verdnatura.es/mylogger'
|
2023-04-11 11:43:15 +00:00
|
|
|
TAG = "${env.VERSION}"
|
2023-04-08 13:08:37 +00:00
|
|
|
CREDENTIALS = credentials('docker-registry')
|
|
|
|
}
|
|
|
|
steps {
|
2023-04-10 12:06:45 +00:00
|
|
|
sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY'
|
2023-04-08 13:08:37 +00:00
|
|
|
sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel'
|
|
|
|
sh 'docker-compose push'
|
2023-04-11 11:36:57 +00:00
|
|
|
|
|
|
|
sh 'docker tag $IMAGE:$TAG $IMAGE:latest'
|
|
|
|
sh 'docker push $IMAGE:latest'
|
2023-04-08 13:08:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
post {
|
|
|
|
unsuccessful {
|
|
|
|
sendEmail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|