Skip to content
Snippets Groups Projects
Commit a2777757 authored by OZGCloud's avatar OZGCloud
Browse files

ozg-7021 info-client fix rollout and docker tag

parent 2466072c
No related branches found
No related tags found
No related merge requests found
......@@ -43,13 +43,6 @@ pipeline {
IMAGE_TAG = generateImageTag()
if (isMasterBranch()) {
IMAGE_TAG = "snapshot-latest"
}
else if (isReleaseBranch()) {
IMAGE_TAG = "latest"
}
loginToDockerRegistry()
sh "INPUT_TAGS=${IMAGE_TAG} INPUT_IMAGES=docker.ozg-sh.de/info-client-by npx nx container info --configuration=production-by"
......@@ -60,6 +53,34 @@ pipeline {
}
}
stage('Tag and Push snapshot-latest Docker image') {
when {
branch 'master'
}
steps {
script {
FAILED_STAGE=env.STAGE_NAME
tagAndPushDockerImage('snapshot-latest')
}
}
}
stage('Tag and Push latest Docker image') {
when {
expression {
isReleaseBranch()
}
}
steps {
script {
FAILED_STAGE=env.STAGE_NAME
tagAndPushDockerImage('latest')
}
}
}
stage('Test, build and deploy info-client HelmChart') {
steps {
script {
......@@ -169,31 +190,44 @@ Void setNewGitopsVersion(String environment) {
envVersions.info_client.helm.version = HELM_CHART_VERSION
writeYaml file: envFile, data: envVersions, overwrite: true
if (hasValuesFileChanged(environment)) {
sh "git add ${envFile}"
sh "git commit -m 'jenkins rollout ${environment} info-client version ${IMAGE_TAG}'"
}
}
Void pushDevGitopsRepo() {
pushNewGitopsVersion('dev')
}
Boolean hasValuesFileChanged(String environment) {
return sh (script: "git status | grep '${environment}/application/values/info-client-values.yaml'", returnStatus: true) == env.SH_SUCCESS_STATUS_CODE as Integer
Void pushTestGitopsRepo() {
pushNewGitopsVersion('test')
}
Void pushNewGitopsVersion(String environment) {
dir('gitops') {
if (!hasGitopsValuesFileChanged(environment)) {
return
}
Void pushGitopsRepo() {
withCredentials([usernamePassword(credentialsId: 'jenkins-gitea-access-token', passwordVariable: 'TOKEN', usernameVariable: 'USER')]) {
dir("gitops") {
if (hasUnpushedCommits()) {
sh "git add ${environment}/application/values/info-client-values.yaml"
sh "git commit -m 'jenkins rollout ${environment} info-client version ${IMAGE_TAG}'"
sh 'git push https://${USER}:${TOKEN}@git.ozg-sh.de/ozgcloud-devops/gitops.git'
}
}
}
Boolean hasGitopsValuesFileChanged(String environment) {
return sh (script: "git status | grep '${environment}/application/values/info-client-values.yaml'", returnStatus: true) == env.SH_SUCCESS_STATUS_CODE as Integer
}
Boolean hasUnpushedCommits() {
return sh (script: "git cherry -v | grep .", returnStatus: true) == env.SH_SUCCESS_STATUS_CODE as Integer
Void tagAndPushDockerImage(String newTag){
loginToDockerRegistry()
sh "docker tag docker.ozg-sh.de/info-client-by:${IMAGE_TAG} docker.ozg-sh.de/info-client-by:${newTag}"
sh "docker push docker.ozg-sh.de/info-client-by:${newTag}"
sh "docker tag docker.ozg-sh.de/info-client-sh:${IMAGE_TAG} docker.ozg-sh.de/info-client-sh:${newTag}"
sh "docker push docker.ozg-sh.de/info-client-sh:${newTag}"
}
Void loginToDockerRegistry(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment