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

Merge branch 'master' into OZG-7047-bugfix

parents b3041660 34fed735
No related branches found
No related tags found
No related merge requests found
...@@ -43,13 +43,6 @@ pipeline { ...@@ -43,13 +43,6 @@ pipeline {
IMAGE_TAG = generateImageTag() IMAGE_TAG = generateImageTag()
if (isMasterBranch()) {
IMAGE_TAG = "snapshot-latest"
}
else if (isReleaseBranch()) {
IMAGE_TAG = "latest"
}
loginToDockerRegistry() loginToDockerRegistry()
sh "INPUT_TAGS=${IMAGE_TAG} INPUT_IMAGES=docker.ozg-sh.de/info-client-by npx nx container info --configuration=production-by" 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 { ...@@ -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') { stage('Test, build and deploy info-client HelmChart') {
steps { steps {
script { script {
...@@ -169,31 +190,44 @@ Void setNewGitopsVersion(String environment) { ...@@ -169,31 +190,44 @@ Void setNewGitopsVersion(String environment) {
envVersions.info_client.helm.version = HELM_CHART_VERSION envVersions.info_client.helm.version = HELM_CHART_VERSION
writeYaml file: envFile, data: envVersions, overwrite: true 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) { Void pushTestGitopsRepo() {
return sh (script: "git status | grep '${environment}/application/values/info-client-values.yaml'", returnStatus: true) == env.SH_SUCCESS_STATUS_CODE as Integer 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')]) { withCredentials([usernamePassword(credentialsId: 'jenkins-gitea-access-token', passwordVariable: 'TOKEN', usernameVariable: 'USER')]) {
dir("gitops") { sh "git add ${environment}/application/values/info-client-values.yaml"
if (hasUnpushedCommits()) {
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' 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() { Void tagAndPushDockerImage(String newTag){
return sh (script: "git cherry -v | grep .", returnStatus: true) == env.SH_SUCCESS_STATUS_CODE as Integer 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(){ Void loginToDockerRegistry(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment