2020-01-15 10:25:33 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
|
|
|
pipeline {
|
2024-06-04 10:36:15 +00:00
|
|
|
agent { label 'kube-agent' }
|
2020-01-15 10:25:33 +00:00
|
|
|
environment {
|
|
|
|
PROJECT_NAME = 'vn-autoconfig'
|
|
|
|
}
|
|
|
|
stages {
|
2024-05-21 20:17:03 +00:00
|
|
|
stage('Setup') {
|
|
|
|
steps {
|
|
|
|
echo "NODE_NAME: ${env.NODE_NAME}"
|
|
|
|
echo "WORKSPACE: ${env.WORKSPACE}"
|
|
|
|
}
|
|
|
|
}
|
2021-04-29 22:03:39 +00:00
|
|
|
stage('Build') {
|
2020-01-15 10:25:33 +00:00
|
|
|
when {
|
|
|
|
branch 'master'
|
|
|
|
}
|
2020-01-31 20:27:53 +00:00
|
|
|
environment {
|
|
|
|
CREDENTIALS = credentials('docker-registry')
|
|
|
|
}
|
|
|
|
steps {
|
2024-05-21 19:28:00 +00:00
|
|
|
script {
|
|
|
|
def packageJson = readJSON file: 'package.json'
|
2024-06-04 10:47:53 +00:00
|
|
|
env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
|
2024-05-21 19:28:00 +00:00
|
|
|
}
|
2021-04-29 22:03:39 +00:00
|
|
|
dockerBuild()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Deploy') {
|
|
|
|
when {
|
|
|
|
branch 'master'
|
|
|
|
}
|
|
|
|
steps {
|
2024-05-21 19:28:00 +00:00
|
|
|
script {
|
|
|
|
def packageJson = readJSON file: 'package.json'
|
2024-06-04 10:47:53 +00:00
|
|
|
env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
|
2024-05-21 19:28:00 +00:00
|
|
|
}
|
2024-05-21 18:52:22 +00:00
|
|
|
withKubeConfig([
|
2024-05-21 20:17:03 +00:00
|
|
|
serverUrl: "$KUBERNETES_API",
|
|
|
|
credentialsId: 'kubernetes',
|
2024-05-21 18:52:22 +00:00
|
|
|
namespace: 'autoconfig'
|
|
|
|
]) {
|
2024-05-27 11:45:47 +00:00
|
|
|
sh 'kubectl set image deployment/autoconfig autoconfig=$REGISTRY/vn-autoconfig:$VERSION'
|
2024-05-21 18:52:22 +00:00
|
|
|
}
|
2020-01-31 20:27:53 +00:00
|
|
|
}
|
2020-01-15 10:25:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
post {
|
|
|
|
always {
|
2024-05-21 18:52:22 +00:00
|
|
|
setEnv()
|
2020-01-31 12:33:02 +00:00
|
|
|
sendEmail()
|
2020-01-15 10:25:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|