#!/usr/bin/env groovy pipeline { agent any environment { PROJECT_NAME = 'vn-rfid' } 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: 'vn-rfid' ]) { sh 'kubectl set image deployment/vn-rfid vn-rfid=$REGISTRY/vn-rfid:$VERSION' } } } } post { always { setEnv() sendEmail() } } }