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