|
@@ -1,5 +1,5 @@
|
|
-@Library('jenkins-library@master') _
|
|
|
|
-def Label = "node-iru-build-${UUID.randomUUID().toString()}"
|
|
|
|
|
|
+@Library('jenkins-library-iru@master') _
|
|
|
|
+def Label = "web-registration-node-build-${UUID.randomUUID().toString()}"
|
|
pipeline {
|
|
pipeline {
|
|
options {
|
|
options {
|
|
buildDiscarder logRotator(numToKeepStr: '10')
|
|
buildDiscarder logRotator(numToKeepStr: '10')
|
|
@@ -13,19 +13,17 @@ pipeline {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
environment {
|
|
environment {
|
|
- CLOUD='cloud-it-k8s'
|
|
|
|
- DOCKER_IMAGE='iru/node'
|
|
|
|
- CHART_SUBPATH='helm/info'
|
|
|
|
- NAMESPACE='info'
|
|
|
|
|
|
+ CONTEXT='provision@sdsys.office'
|
|
|
|
+ DOCKER_IMAGE='web-registration/node'
|
|
HELM_GIT_URL='ssh://git@git.sdsys.ru:8022/iru/k8s.git'
|
|
HELM_GIT_URL='ssh://git@git.sdsys.ru:8022/iru/k8s.git'
|
|
APP_GIT_URL='ssh://git@git.sdsys.ru:8022/iru/node.git'
|
|
APP_GIT_URL='ssh://git@git.sdsys.ru:8022/iru/node.git'
|
|
JENKINS_MAIL='jenkins.dev@sdsys.ru'
|
|
JENKINS_MAIL='jenkins.dev@sdsys.ru'
|
|
- DOCKER_REGISTRY='jcr.infoclinica.ru'
|
|
|
|
|
|
+ DOCKER_REGISTRY='images.sdsys.ru'
|
|
PROJECT=''
|
|
PROJECT=''
|
|
CHART_NAME=''
|
|
CHART_NAME=''
|
|
CHART_PATH=''
|
|
CHART_PATH=''
|
|
HELM_DIR=''
|
|
HELM_DIR=''
|
|
- TAG=''
|
|
|
|
|
|
+ IMAGE_TO_PUSH=''
|
|
}
|
|
}
|
|
parameters {
|
|
parameters {
|
|
string(
|
|
string(
|
|
@@ -43,46 +41,50 @@ pipeline {
|
|
stage("Prepare to Build") {
|
|
stage("Prepare to Build") {
|
|
steps {
|
|
steps {
|
|
script {
|
|
script {
|
|
|
|
+ echo "GIT clone ${HELM_GIT_URL}"
|
|
gitOps.clone(HELM_GIT_URL)
|
|
gitOps.clone(HELM_GIT_URL)
|
|
|
|
+ echo "Defining variables"
|
|
HELM_DIR = dirOps.calculateDir(HELM_GIT_URL)
|
|
HELM_DIR = dirOps.calculateDir(HELM_GIT_URL)
|
|
- CHART_PATH = "${HELM_DIR}/${CHART_SUBPATH}"
|
|
|
|
|
|
+ CHART_PATH = HELM_DIR + "/" + helm + "/" + DOCKER_IMAGE.split("/")[2]
|
|
PROJECT = DOCKER_IMAGE.split("/")[1]
|
|
PROJECT = DOCKER_IMAGE.split("/")[1]
|
|
|
|
+ VALUES_FILE = "${CHART_PATH}/dev.yaml"
|
|
|
|
+ IMAGE_TO_PUSH = "${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${repo}-${BUILD_NUMBER}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage("Build Image") {
|
|
stage("Build Image") {
|
|
steps {
|
|
steps {
|
|
script {
|
|
script {
|
|
- echo "Build Image with Kaniko"
|
|
|
|
- REGISTRY = "${DOCKER_REGISTRY}/${DOCKER_IMAGE}"
|
|
|
|
|
|
+ echo "Building ${IMAGE_TO_PUSH} with Kaniko"
|
|
ARGS = [ "repo=${repo}" ]
|
|
ARGS = [ "repo=${repo}" ]
|
|
- TAG = "${repo}-${BUILD_NUMBER}"
|
|
|
|
- k8sBuildImage.kaniko(REGISTRY, TAG, ARGS)
|
|
|
|
|
|
+ k8sBuildImage.kaniko(IMAGE_TO_PUSH, ARGS)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- stage("Update Helm Chart values.yaml") {
|
|
|
|
|
|
+ stage("Update Helm Chart") {
|
|
steps {
|
|
steps {
|
|
script {
|
|
script {
|
|
- echo "Update Helm Chart"
|
|
|
|
- def data = readYaml file: "${CHART_PATH}/values.yaml"
|
|
|
|
- TAG_PATH = "images.${PROJECT}.dev"
|
|
|
|
- yamlOps.updateBuilder(TAG_PATH, data, TAG)
|
|
|
|
- writeYaml file: "${CHART_PATH}/values.yaml", data: data, overwrite: true
|
|
|
|
|
|
+ TAG_PATH = "images.${PROJECT}"
|
|
|
|
+ echo "Update ${TAG_PATH} to ${IMAGE_TO_PUSH} in ${VALUES_FILE}"
|
|
|
|
+ def data = readYaml file: "${VALUES_FILE}"
|
|
|
|
+ yamlOps.updateBuilder(TAG_PATH, data, IMAGE_TO_PUSH)
|
|
|
|
+ writeYaml file: "${VALUES_FILE}", data: data, overwrite: true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage("Update APP") {
|
|
stage("Update APP") {
|
|
steps {
|
|
steps {
|
|
script {
|
|
script {
|
|
- RELEASENAME = CHART_SUBPATH.split("/")[1]
|
|
|
|
|
|
+ RELEASENAME = DOCKER_IMAGE.split("/")[0]
|
|
|
|
+ NAMESPACE = DOCKER_IMAGE.split("/")[0]
|
|
try {
|
|
try {
|
|
- echo "Update APP"
|
|
|
|
- k8sHelmOps.upgrade(CLOUD, NAMESPACE, RELEASENAME, CHART_PATH)
|
|
|
|
|
|
+ echo "Update APP to ${IMAGE_TO_PUSH}"
|
|
|
|
+ k8sHelmOps.upgrade(CONTEXT, NAMESPACE, RELEASENAME, CHART_PATH, VALUES_FILE)
|
|
|
|
+ echo "Update success!!!"
|
|
}
|
|
}
|
|
catch(err) {
|
|
catch(err) {
|
|
echo "Recovering APP"
|
|
echo "Recovering APP"
|
|
- k8sHelmOps.rollback(CLOUD, NAMESPACE, RELEASENAME)
|
|
|
|
|
|
+ k8sHelmOps.rollback(CONTEXT, NAMESPACE, RELEASENAME)
|
|
throw err
|
|
throw err
|
|
}
|
|
}
|
|
}
|
|
}
|