#!/usr/bin/env groovy pipeline { agent any environment { PROJECT_NAME = 'printnatura' } stages { stage('Setup') { steps { echo "NODE_NAME: ${env.NODE_NAME}" echo "WORKSPACE: ${env.WORKSPACE}" } } stage('Build') { when { branch 'master' } environment { CREDENTIALS = credentials('docker-registry') } steps { script { def packageJson = readJSON file: 'package.json' env.VERSION = packageJson.version } dockerBuild() } } stage('Deploy') { when { branch 'master' } steps { script { def packageJson = readJSON file: 'package.json' env.VERSION = packageJson.version } withKubeConfig([ serverUrl: "$KUBERNETES_API", credentialsId: 'kubernetes', namespace: 'printnatura' ]) { sh 'kubectl set image deployment/printnatura printnatura=registry.verdnatura.es/printnatura:$VERSION' } } } } post { always { setEnv() sendEmail() } } }