49 lines
1.3 KiB
Groovy
49 lines
1.3 KiB
Groovy
#!/usr/bin/env groovy
|
|
|
|
pipeline {
|
|
agent any
|
|
environment {
|
|
PROJECT_NAME = 'vn-autoconfig'
|
|
}
|
|
stages {
|
|
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.verdnatura.es/vn-autoconfig:$VERSION'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
setEnv()
|
|
sendEmail()
|
|
}
|
|
}
|
|
} |