hotfix/DO-00/some_refactoring (!59)

Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.tech>
Reviewed-on: https://git.avroid.tech/DevOps/jenkins-pipelines/pulls/59
This commit is contained in:
Rustam Tagaev
2024-12-20 16:27:23 +03:00
parent b62d3069f0
commit 98730dde31

View File

@@ -19,6 +19,7 @@ String valuesPath = 'avroid.local/api-gateway/openresty'
String namespace = 'api-gateway' String namespace = 'api-gateway'
String helmChart = 'openresty' String helmChart = 'openresty'
String helmRepoPath = 'avroid/openresty' String helmRepoPath = 'avroid/openresty'
String helmRepo = "${env.JENKINS_NEXUS_URL}/repository/avroid-charts"
Map configuration = [ Map configuration = [
vaultUrl: env.JENKINS_VAULT_URL, vaultUrl: env.JENKINS_VAULT_URL,
@@ -40,46 +41,44 @@ PodTemplates slaveTemplates = new PodTemplates(this, env.JENKINS_DOCKER_REGISTRY
slaveTemplates.jnlp { slaveTemplates.jnlp {
slaveTemplates.helm { slaveTemplates.helm {
slaveTemplates.kubectl { try {
try { node(POD_LABEL){
node(POD_LABEL){ withVault([configuration: configuration, vaultSecrets: dockerCreds]) {
withVault([configuration: configuration, vaultSecrets: dockerCreds]) { stage('get repo with values'){
stage('get repo with values'){ gitVars = git.clone([urlRepo: "${env.JENKINS_GIT_REPOSITORY_SSH_URL}/${repoPath}",
gitVars = git.clone([urlRepo: "${env.JENKINS_GIT_REPOSITORY_SSH_URL}/${repoPath}", branch: branch])
branch: branch]) }
} container('helm'){
container('helm'){ stage('deploy'){
stage('deploy'){ dir(valuesPath){
dir(valuesPath){ sh """#!/bin/sh
sh """#!/bin/sh helm repo add avroid ${helmRepo}
helm repo add avroid ${env.JENKINS_NEXUS_URL}/repository/devops-helm-release helm -n ${namespace} upgrade -f values.yaml \
helm -n ${namespace} upgrade -f values.yaml --install ${helmChart} ${helmRepoPath} --install ${helmChart} ${helmRepoPath}
""" """
}
} }
} }
} }
} }
} catch(err) {
errorMessage = err.getMessage()
println 'ERROR: ' + errorMessage
currentBuild.result = 'FAILURE'
String currentBuildUser = Jenkins.GetCurrentBuildUser(script: this)
String emailSubject = "${currentBuild.currentResult}. " +
"Pipeline task: ${currentBuild.fullDisplayName}"
Notifications.email(
script: this,
subject: emailSubject,
errorString: errorMessage,
recipientProviders: [],
to: "${currentBuildUser}@avroid.team"
)
} }
} catch(err) {
errorMessage = err.getMessage()
println 'ERROR: ' + errorMessage
currentBuild.result = 'FAILURE'
String currentBuildUser = Jenkins.GetCurrentBuildUser(script: this)
String emailSubject = "${currentBuild.currentResult}. " +
"Pipeline task: ${currentBuild.fullDisplayName}"
Notifications.email(
script: this,
subject: emailSubject,
errorString: errorMessage,
recipientProviders: [],
to: "${currentBuildUser}@avroid.team"
)
} }
} }
} }