refactor: feat #7441 Migration to kube
gitea/printnatura/pipeline/pr-master This commit looks good
Details
gitea/printnatura/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
c6bd546fb9
commit
cac0583a5c
|
@ -4,43 +4,32 @@ pipeline {
|
|||
agent any
|
||||
environment {
|
||||
PROJECT_NAME = 'printnatura'
|
||||
STACK_NAME = "${env.PROJECT_NAME}"
|
||||
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('Container') {
|
||||
when {
|
||||
anyOf {
|
||||
branch 'test'
|
||||
branch 'master'
|
||||
}
|
||||
}
|
||||
stage('Build') {
|
||||
when {branch 'master'}
|
||||
environment {
|
||||
CREDS = credentials('docker-registry')
|
||||
IMAGE = 'registry.verdnatura.es/printnatura'
|
||||
TAG = "${env.VERSION}"
|
||||
CREDENTIALS = credentials('docker-registry')
|
||||
}
|
||||
steps {
|
||||
sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY'
|
||||
sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY'
|
||||
sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel'
|
||||
sh 'docker-compose push'
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
when {
|
||||
anyOf {
|
||||
branch 'test'
|
||||
branch 'master'
|
||||
}
|
||||
}
|
||||
environment {
|
||||
DOCKER_HOST = "${env.SWARM_HOST}"
|
||||
CUPS = credentials('printnatura')
|
||||
}
|
||||
steps {
|
||||
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
|
||||
|
||||
sh 'docker tag $IMAGE:$TAG $IMAGE:latest'
|
||||
sh 'docker push $IMAGE:latest'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue