2021-10-18 08:54:32 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
environment {
|
2021-10-20 13:26:27 +00:00
|
|
|
PROJECT_NAME = 'worker-time-control'
|
2021-10-18 08:54:32 +00:00
|
|
|
}
|
|
|
|
stages {
|
|
|
|
stage('Checkout') {
|
|
|
|
steps {
|
2024-05-27 11:11:57 +00:00
|
|
|
echo "NODE_NAME: ${env.NODE_NAME}"
|
|
|
|
echo "WORKSPACE: ${env.WORKSPACE}"
|
2021-10-18 08:54:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Build') {
|
2021-10-21 11:41:24 +00:00
|
|
|
when { anyOf {
|
|
|
|
branch 'test'
|
|
|
|
branch 'master'
|
|
|
|
}}
|
2021-10-18 08:54:32 +00:00
|
|
|
environment {
|
|
|
|
CREDENTIALS = credentials('docker-registry')
|
|
|
|
}
|
|
|
|
steps {
|
2024-05-27 11:11:57 +00:00
|
|
|
script {
|
|
|
|
def packageJson = readJSON file: 'package.json'
|
|
|
|
env.VERSION = packageJson.version
|
|
|
|
}
|
2021-10-18 08:54:32 +00:00
|
|
|
dockerBuild()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Deploy') {
|
2021-10-21 11:41:24 +00:00
|
|
|
when { anyOf {
|
|
|
|
branch 'test'
|
|
|
|
branch 'master'
|
|
|
|
}}
|
2021-10-18 08:54:32 +00:00
|
|
|
steps {
|
2024-05-27 11:11:57 +00:00
|
|
|
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'
|
|
|
|
}
|
2021-10-18 08:54:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
post {
|
|
|
|
always {
|
2024-05-27 11:11:57 +00:00
|
|
|
setEnv()
|
2021-10-18 08:54:32 +00:00
|
|
|
sendEmail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|