mylogger/Jenkinsfile

48 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

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'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
IMAGE = 'registry.verdnatura.es/mylogger'
2023-04-08 13:08:37 +00:00
}
stages {
stage('Build') {
when {branch 'master'}
2023-04-08 13:08:37 +00:00
steps {
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
}
sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel'
sh 'docker tag $IMAGE:$VERSION $IMAGE:latest'
2023-04-08 13:08:37 +00:00
}
}
stage('Push') {
2023-04-08 13:08:37 +00:00
when {branch 'master'}
environment {
CREDENTIALS = credentials('docker-registry')
}
steps {
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
}
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 push'
2023-04-11 11:36:57 +00:00
sh 'docker push $IMAGE:latest'
2023-04-08 13:08:37 +00:00
}
}
}
post {
unsuccessful {
setEnv()
2023-04-08 13:08:37 +00:00
sendEmail()
}
}
}