vn-autoconfig/Jenkinsfile

55 lines
1.4 KiB
Groovy

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