|
@@ -1,9 +1,10 @@
|
|
@Library('jenkins-library@master') _
|
|
@Library('jenkins-library@master') _
|
|
-def Label = "admin-build-${UUID.randomUUID().toString()}"
|
|
|
|
|
|
+def Label = "node-iru-build-${UUID.randomUUID().toString()}"
|
|
pipeline {
|
|
pipeline {
|
|
options {
|
|
options {
|
|
buildDiscarder logRotator(numToKeepStr: '10')
|
|
buildDiscarder logRotator(numToKeepStr: '10')
|
|
disableConcurrentBuilds()
|
|
disableConcurrentBuilds()
|
|
|
|
+ timeout(time: 10, unit: 'MINUTES')
|
|
}
|
|
}
|
|
agent {
|
|
agent {
|
|
kubernetes {
|
|
kubernetes {
|
|
@@ -14,14 +15,15 @@ pipeline {
|
|
environment {
|
|
environment {
|
|
CLOUD='cloud-it-k8s'
|
|
CLOUD='cloud-it-k8s'
|
|
DOCKER_IMAGE='iru/node'
|
|
DOCKER_IMAGE='iru/node'
|
|
- CHART_PATH='helm/info'
|
|
|
|
|
|
+ CHART_SUBPATH='helm/info'
|
|
NAMESPACE='info'
|
|
NAMESPACE='info'
|
|
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='jcr.infoclinica.ru'
|
|
CHART_NAME=''
|
|
CHART_NAME=''
|
|
- APP_DIR=''
|
|
|
|
|
|
+ CHART_PATH=''
|
|
|
|
+ PROJECT=''
|
|
HELM_DIR=''
|
|
HELM_DIR=''
|
|
TAG=''
|
|
TAG=''
|
|
}
|
|
}
|
|
@@ -39,6 +41,8 @@ pipeline {
|
|
echo "Pull Repo"
|
|
echo "Pull Repo"
|
|
gitOps.clone(HELM_GIT_URL)
|
|
gitOps.clone(HELM_GIT_URL)
|
|
HELM_DIR = dirOps.calculateDir(HELM_GIT_URL)
|
|
HELM_DIR = dirOps.calculateDir(HELM_GIT_URL)
|
|
|
|
+ CHART_PATH = "${HELM_DIR}/${CHART_SUBPATH}"
|
|
|
|
+ PROJECT = DOCKER_IMAGE.split("/")[1]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -46,28 +50,26 @@ pipeline {
|
|
steps {
|
|
steps {
|
|
script {
|
|
script {
|
|
echo "Update values.yaml"
|
|
echo "Update values.yaml"
|
|
- APP_DIR = dirOps.calculateDir(APP_GIT_URL)
|
|
|
|
- def data = readYaml file: "${HELM_DIR}/${CHART_PATH}/values.yaml"
|
|
|
|
- TAG_PATH = "images.${APP_DIR}.dev"
|
|
|
|
|
|
+ def data = readYaml file: "${CHART_PATH}/values.yaml"
|
|
|
|
+ TAG_PATH = "images.${PROJECT}.dev"
|
|
TAG = yamlOps.getBuilder(TAG_PATH, data)
|
|
TAG = yamlOps.getBuilder(TAG_PATH, data)
|
|
- TAG_PATH = "images.${APP_DIR}.prod"
|
|
|
|
|
|
+ TAG_PATH = "images.${PROJECT}.prod"
|
|
yamlOps.updateBuilder(TAG_PATH, data, TAG)
|
|
yamlOps.updateBuilder(TAG_PATH, data, TAG)
|
|
- writeYaml file: "${HELM_DIR}/${CHART_PATH}/values.yaml", data: data, overwrite: true
|
|
|
|
|
|
+ writeYaml file: "${CHART_PATH}/values.yaml", data: data, overwrite: true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage("Update APP") {
|
|
stage("Update APP") {
|
|
steps {
|
|
steps {
|
|
script {
|
|
script {
|
|
- CHART = "${HELM_DIR}/${CHART_PATH}"
|
|
|
|
- CHART_NAME = CHART_PATH.split("/")[1]
|
|
|
|
|
|
+ RELEASENAME = CHART_SUBPATH.split("/")[1]
|
|
try {
|
|
try {
|
|
echo "Update APP"
|
|
echo "Update APP"
|
|
- k8sHelmOps.upgrade(CLOUD, NAMESPACE, CHART_NAME, CHART, 'prod')
|
|
|
|
|
|
+ k8sHelmOps.upgrade(CLOUD, NAMESPACE, RELEASENAME, CHART_PATH, 'dev')
|
|
}
|
|
}
|
|
catch(err) {
|
|
catch(err) {
|
|
echo "Recovering APP"
|
|
echo "Recovering APP"
|
|
- k8sHelmOps.rollback(CLOUD, NAMESPACE, CHART_NAME)
|
|
|
|
|
|
+ k8sHelmOps.rollback(CLOUD, NAMESPACE, RELEASENAME)
|
|
throw err
|
|
throw err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -77,7 +79,7 @@ pipeline {
|
|
steps {
|
|
steps {
|
|
script {
|
|
script {
|
|
echo "Push changes to Repo"
|
|
echo "Push changes to Repo"
|
|
- COMMIT = "Version update ${APP_DIR}"
|
|
|
|
|
|
+ COMMIT = "Version update ${PROJECT}"
|
|
gitOps.push(HELM_DIR, COMMIT)
|
|
gitOps.push(HELM_DIR, COMMIT)
|
|
}
|
|
}
|
|
}
|
|
}
|