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

OZG-3293 argocd rollout

parent 850e9c96
Branches
Tags
No related merge requests found
......@@ -10,6 +10,7 @@ pipeline {
RELEASE_REGEX = /\d+.\d+.\d+/
SNAPSHOT_REGEX = /\d+.\d+.\d+-SNAPSHOT/
FAILED_STAGE = ""
SH_SUCCESS_STATUS_CODE = 0
//The container runtime (e.g. docker) that is used to do an image based build. If this is set then a container build is always done.
QUARKUS_NATIVE_CONTAINER_RUNTIME = "docker"
......@@ -156,16 +157,16 @@ pipeline {
script {
FAILED_STAGE = env.STAGE_NAME
checkoutGitopsRepo()
cloneGitopsRepo()
setNewGitopsVersion('dev')
setNewDevUserManagerVersion()
pushNewGitopsVersion('dev')
pushDevGitopsRepo()
}
}
}
stage('Trigger Test | Stage rollout') {
stage('Trigger Test rollout') {
when {
branch 'release'
}
......@@ -174,11 +175,11 @@ pipeline {
script {
FAILED_STAGE = env.STAGE_NAME
checkoutGitopsRepo()
cloneGitopsRepo()
setNewGitopsVersion('test')
setNewTestUserManagerVersion()
pushNewGitopsVersion('test')
pushTestGitopsRepo()
}
}
}
......@@ -246,6 +247,14 @@ String getElementAccessToken() {
}
}
Void setNewDevUserManagerVersion() {
setNewGitopsVersion('dev')
}
Void setNewTestUserManagerVersion() {
setNewGitopsVersion('test')
}
Void setNewGitopsVersion(String environment) {
dir("gitops") {
def envFile = "${environment}/application/values/user-manager-values.yaml"
......@@ -259,29 +268,51 @@ Void setNewGitopsVersion(String environment) {
}
}
Void checkoutGitopsRepo() {
Void configGit() {
final email = "jenkins@ozg-sh.de"
final name = "jenkins"
dir("gitops") {
sh "git config user.email '${email}'"
sh "git config user.name '${name}'"
}
}
Void cloneGitopsRepo() {
withCredentials([usernamePassword(credentialsId: 'jenkins-gitea-access-token', passwordVariable: 'TOKEN', usernameVariable: 'USER')]) {
sh 'git clone https://${USER}:${TOKEN}@git.ozg-sh.de/mgm/gitops.git'
}
configGit()
}
Void pushDevGitopsRepo(){
pushNewGitopsVersion('dev')
}
Void pushTestGitopsRepo(){
pushNewGitopsVersion('test')
}
Void pushNewGitopsVersion(String environment) {
dir('gitops') {
if (sh (script: "git status | grep '${environment}/application/values/user-manager-values.yaml'", returnStatus: true) == 1) {
if (!hasUserManagerValuesFileChanged(environment)) {
return
}
withCredentials([usernamePassword(credentialsId: 'jenkins-gitea-access-token', passwordVariable: 'TOKEN', usernameVariable: 'USER')]) {
sh "git add ${environment}/application/values/user-manager-values.yaml"
sh 'git config user.email "jenkins@ozg-sh.de"'
sh 'git config user.name "jenkins"'
sh "git commit -m 'jenkins rollout ${environment} user-manager version ${IMAGE_TAG}'"
sh 'git push https://${USER}:${TOKEN}@git.ozg-sh.de/mgm/gitops.git'
}
}
}
Boolean hasUserManagerValuesFileChanged(String environment) {
return sh (script: "git status | grep '${environment}/application/values/user-manager-values.yaml'", returnStatus: true) == env.SH_SUCCESS_STATUS_CODE as Integer
}
String getPomVersion(String pomFile){
def pom = readMavenPom file: pomFile
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment