From 51af112610784a137d202e20691f85e730748f45 Mon Sep 17 00:00:00 2001 From: Daniel Mann Date: Tue, 15 Jul 2025 10:24:50 +0200 Subject: [PATCH 01/10] Update Jenkinsfile --- Jenkinsfile | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 6d2f479..465961b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -80,6 +80,38 @@ pipeline { } } } + + stage('Update helm chart repository') { + when { + branch 'development' + } + steps { + script { + def newTag = "0.${env.BUILD_ID}" + def chartRepo = "https://jenkins:${env.TOKEN}@gitea.innovation-hub-niedersachsen.de/innohub/charts.git" + def chartPath = "tatort-dev/tatort" + + sh """ + rm -rf charts-tmp + git clone ${chartRepo} charts-tmp + cd charts-tmp/${chartPath} + + # update image tag in values.yaml + sed -i 's/^ tag: .*/ tag: ${newTag}/' values.yaml + + # optional: bump version in Chart.yaml + sed -i 's/^version: .*/version: ${newTag}/' Chart.yaml + sed -i 's/^appVersion: .*/appVersion: ${newTag}/' Chart.yaml + + git config user.name 'Jenkins' + git config user.email 'jenkins@innohub.local' + git add values.yaml Chart.yaml + git commit -m 'ci: update tatort-dev chart with image tag ${newTag}' + git push origin main + """ + } + } + } } post { From 73c551c9dee3670f8e7192c908166eb00b653e30 Mon Sep 17 00:00:00 2001 From: Daniel Mann Date: Tue, 15 Jul 2025 10:49:51 +0200 Subject: [PATCH 02/10] Update Jenkinsfile --- Jenkinsfile | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 465961b..ea554d6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -81,38 +81,40 @@ pipeline { } } - stage('Update helm chart repository') { + stage('Update Helm Chart Repository') { when { branch 'development' } steps { - script { - def newTag = "0.${env.BUILD_ID}" - def chartRepo = "https://jenkins:${env.TOKEN}@gitea.innovation-hub-niedersachsen.de/innohub/charts.git" - def chartPath = "tatort-dev/tatort" + withCredentials([usernamePassword(credentialsId: 'JenkinsGitea', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PAT')]) { + script { + def newTag = "0.${env.BUILD_ID}" + def chartRepo = "https://${GIT_USER}:${GIT_PAT}@gitea.innovation-hub-niedersachsen.de/innohub/charts.git" + def chartPath = "tatort-dev/tatort" - sh """ - rm -rf charts-tmp - git clone ${chartRepo} charts-tmp - cd charts-tmp/${chartPath} + sh """ + # Clean clone + rm -rf charts-tmp + git clone ${chartRepo} charts-tmp + cd charts-tmp/${chartPath} - # update image tag in values.yaml - sed -i 's/^ tag: .*/ tag: ${newTag}/' values.yaml + # Update values.yaml image tag + sed -i 's/^ tag: .*/ tag: ${newTag}/' values.yaml - # optional: bump version in Chart.yaml - sed -i 's/^version: .*/version: ${newTag}/' Chart.yaml - sed -i 's/^appVersion: .*/appVersion: ${newTag}/' Chart.yaml + # Optional: bump chart version and appVersion + sed -i 's/^version: .*/version: ${newTag}/' Chart.yaml + sed -i 's/^appVersion: .*/appVersion: ${newTag}/' Chart.yaml - git config user.name 'Jenkins' - git config user.email 'jenkins@innohub.local' - git add values.yaml Chart.yaml - git commit -m 'ci: update tatort-dev chart with image tag ${newTag}' - git push origin main - """ + git config user.name "jenkins" + git config user.email "jenkins@innohub.local" + git add values.yaml Chart.yaml + git commit -m "ci: update tatort-dev chart with image tag ${newTag}" + git push origin main + """ + } } } } - } post { success { From c5202bb75716b2baa8f19961ea8f332f9ce73320 Mon Sep 17 00:00:00 2001 From: Daniel Mann Date: Tue, 15 Jul 2025 10:53:14 +0200 Subject: [PATCH 03/10] Update Jenkinsfile --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ea554d6..3148580 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -115,7 +115,8 @@ pipeline { } } } - + } + post { success { script { From 24443496940b65c8c482c66615326f4586dd09d9 Mon Sep 17 00:00:00 2001 From: Daniel Mann Date: Tue, 15 Jul 2025 11:08:26 +0200 Subject: [PATCH 04/10] Update Jenkinsfile --- Jenkinsfile | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3148580..14db86b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -86,29 +86,42 @@ pipeline { branch 'development' } steps { - withCredentials([usernamePassword(credentialsId: 'JenkinsGitea', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PAT')]) { + withCredentials([ + usernamePassword( + credentialsId: 'JenkinsGitea', + usernameVariable: 'GIT_USER', + passwordVariable: 'GIT_PAT' + ) + ]) { script { def newTag = "0.${env.BUILD_ID}" def chartRepo = "https://${GIT_USER}:${GIT_PAT}@gitea.innovation-hub-niedersachsen.de/innohub/charts.git" def chartPath = "tatort-dev/tatort" + def chartDir = "charts-tmp/${chartPath}" sh """ - # Clean clone + set -e + rm -rf charts-tmp git clone ${chartRepo} charts-tmp - cd charts-tmp/${chartPath} + cd ${chartDir} - # Update values.yaml image tag + echo "[INFO] Updating values.yaml and Chart.yaml..." sed -i 's/^ tag: .*/ tag: ${newTag}/' values.yaml - - # Optional: bump chart version and appVersion sed -i 's/^version: .*/version: ${newTag}/' Chart.yaml sed -i 's/^appVersion: .*/appVersion: ${newTag}/' Chart.yaml - git config user.name "jenkins" + echo "[INFO] Packaging chart..." + helm package . + + echo "[INFO] Updating index.yaml..." + helm repo index . --merge index.yaml || helm repo index . + + echo "[INFO] Committing Helm chart changes..." + git config user.name "Jenkins" git config user.email "jenkins@innohub.local" - git add values.yaml Chart.yaml - git commit -m "ci: update tatort-dev chart with image tag ${newTag}" + git add values.yaml Chart.yaml *.tgz index.yaml + git commit -m "ci: bump tatort chart to ${newTag}, package + index" git push origin main """ } @@ -116,7 +129,7 @@ pipeline { } } } - + post { success { script { From 4633769366ed6432abdf83334761be700ffc9347 Mon Sep 17 00:00:00 2001 From: Daniel Mann Date: Tue, 15 Jul 2025 11:28:34 +0200 Subject: [PATCH 05/10] Update Jenkinsfile --- Jenkinsfile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 14db86b..db91269 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -111,16 +111,22 @@ pipeline { sed -i 's/^version: .*/version: ${newTag}/' Chart.yaml sed -i 's/^appVersion: .*/appVersion: ${newTag}/' Chart.yaml - echo "[INFO] Packaging chart..." - helm package . + echo "[INFO] Removing old chart packages..." + cd .. + rm -f tatort-*.tgz - echo "[INFO] Updating index.yaml..." + echo "[INFO] Packaging chart into parent dir..." + cd tatort + helm package . --destination .. + + echo "[INFO] Updating index.yaml in parent dir..." + cd .. helm repo index . --merge index.yaml || helm repo index . echo "[INFO] Committing Helm chart changes..." git config user.name "Jenkins" git config user.email "jenkins@innohub.local" - git add values.yaml Chart.yaml *.tgz index.yaml + git add tatort/values.yaml tatort/Chart.yaml tatort-*.tgz index.yaml git commit -m "ci: bump tatort chart to ${newTag}, package + index" git push origin main """ From d9bcad9f7795592b2273d1a0ac815054f0c9d5b0 Mon Sep 17 00:00:00 2001 From: Daniel Mann Date: Tue, 15 Jul 2025 11:42:23 +0200 Subject: [PATCH 06/10] Update Jenkinsfile --- Jenkinsfile | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index db91269..7b3097c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -94,40 +94,44 @@ pipeline { ) ]) { script { - def newTag = "0.${env.BUILD_ID}" + def newTag = "0.${env.BUILD_ID}-dev.1" def chartRepo = "https://${GIT_USER}:${GIT_PAT}@gitea.innovation-hub-niedersachsen.de/innohub/charts.git" def chartPath = "tatort-dev/tatort" def chartDir = "charts-tmp/${chartPath}" + def chartRepoRoot = "charts-tmp/tatort-dev" sh """ set -e + echo "[INFO] Cloning chart repo..." rm -rf charts-tmp git clone ${chartRepo} charts-tmp - cd ${chartDir} echo "[INFO] Updating values.yaml and Chart.yaml..." + cd ${chartDir} + sed -i 's|^ repository: .*| repository: gitea.innovation-hub-niedersachsen.de/innohub/tatort-dev|' values.yaml sed -i 's/^ tag: .*/ tag: ${newTag}/' values.yaml sed -i 's/^version: .*/version: ${newTag}/' Chart.yaml sed -i 's/^appVersion: .*/appVersion: ${newTag}/' Chart.yaml - echo "[INFO] Removing old chart packages..." + echo "[INFO] Cleaning up old chart packages..." cd .. + rm -f index.yaml rm -f tatort-*.tgz - echo "[INFO] Packaging chart into parent dir..." + echo "[INFO] Packaging Helm chart..." cd tatort helm package . --destination .. - echo "[INFO] Updating index.yaml in parent dir..." + echo "[INFO] Updating Helm index.yaml..." cd .. helm repo index . --merge index.yaml || helm repo index . - echo "[INFO] Committing Helm chart changes..." + echo "[INFO] Committing and pushing chart changes..." git config user.name "Jenkins" git config user.email "jenkins@innohub.local" git add tatort/values.yaml tatort/Chart.yaml tatort-*.tgz index.yaml - git commit -m "ci: bump tatort chart to ${newTag}, package + index" + git commit -m "ci: bump tatort-dev to ${newTag}, package chart + update index" git push origin main """ } From 552350354b6d277227963e52c489d9eddea623df Mon Sep 17 00:00:00 2001 From: Daniel Mann Date: Tue, 15 Jul 2025 11:54:50 +0200 Subject: [PATCH 07/10] Update Jenkinsfile --- Jenkinsfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7b3097c..c3f314f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -73,9 +73,13 @@ pipeline { steps { script { didRun = true - def tag = "innohub/tatort-dev:0.${env.BUILD_ID}" + def versionTag = "0.${env.BUILD_ID}-dev.1" + def imageName = "gitea.innovation-hub-niedersachsen.de/innohub/tatort-dev" + docker.withRegistry('https://gitea.innovation-hub-niedersachsen.de', 'JenkinsGitea') { - docker.build(tag, '-f Dockerfile.dev .').push('latest') + def img = docker.build("${imageName}:${versionTag}", '-f Dockerfile.dev .') + img.push() + img.push('latest') // Optional if you want to keep 'latest' tag } } } From 6786f768f0c7f239afc425f6ddd509ac0b5bf1f6 Mon Sep 17 00:00:00 2001 From: Daniel Mann Date: Tue, 15 Jul 2025 12:07:53 +0200 Subject: [PATCH 08/10] Update Jenkinsfile --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c3f314f..8aa5902 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -122,6 +122,7 @@ pipeline { cd .. rm -f index.yaml rm -f tatort-*.tgz + git rm -f tatort-*.tgz || true echo "[INFO] Packaging Helm chart..." cd tatort @@ -132,7 +133,7 @@ pipeline { helm repo index . --merge index.yaml || helm repo index . echo "[INFO] Committing and pushing chart changes..." - git config user.name "Jenkins" + git config user.name "jenkins" git config user.email "jenkins@innohub.local" git add tatort/values.yaml tatort/Chart.yaml tatort-*.tgz index.yaml git commit -m "ci: bump tatort-dev to ${newTag}, package chart + update index" From a7527ccf22ac1406abe0f1bc0e530fc7a1bb6bda Mon Sep 17 00:00:00 2001 From: Daniel Mann Date: Wed, 16 Jul 2025 09:40:46 +0200 Subject: [PATCH 09/10] Update Jenkinsfile --- Jenkinsfile | 77 +++++++++++++++++------------------------------------ 1 file changed, 24 insertions(+), 53 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8aa5902..6001215 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,7 @@ pipeline { } environment { + VERSION_TAG = 'null' REGISTRY = 'https://gitea.innovation-hub-niedersachsen.de/' USER = 'jenkins' TOKEN = credentials('JenkinsGitea') @@ -31,6 +32,14 @@ pipeline { } stages { + stage('Set Version Tag') { + steps { + script { + env.VERSION_TAG = generateVersionTag(params.GIT_REF) + echo "[INFO] Using VERSION_TAG: ${env.VERSION_TAG}" + } + } + } stage('Validate Repository') { steps { script { @@ -72,15 +81,15 @@ pipeline { } steps { script { - didRun = true - def versionTag = "0.${env.BUILD_ID}-dev.1" def imageName = "gitea.innovation-hub-niedersachsen.de/innohub/tatort-dev" - docker.withRegistry('https://gitea.innovation-hub-niedersachsen.de', 'JenkinsGitea') { - def img = docker.build("${imageName}:${versionTag}", '-f Dockerfile.dev .') + docker.withRegistry(REGISTRY, 'JenkinsGitea') { + def img = docker.build("${imageName}:${env.VERSION_TAG}", '-f Dockerfile.dev .') img.push() - img.push('latest') // Optional if you want to keep 'latest' tag + img.push('latest') } + + didRun = true } } } @@ -90,56 +99,18 @@ pipeline { branch 'development' } steps { - withCredentials([ - usernamePassword( + script { + updateHelmChart([ + tag: env.VERSION_TAG, + repoUrl: 'gitea.innovation-hub-niedersachsen.de/innohub/charts.git', + chartPath: 'tatort-dev/tatort', + chartName: 'tatort', + imageRepo: 'gitea.innovation-hub-niedersachsen.de/innohub/tatort-dev', credentialsId: 'JenkinsGitea', - usernameVariable: 'GIT_USER', - passwordVariable: 'GIT_PAT' - ) - ]) { - script { - def newTag = "0.${env.BUILD_ID}-dev.1" - def chartRepo = "https://${GIT_USER}:${GIT_PAT}@gitea.innovation-hub-niedersachsen.de/innohub/charts.git" - def chartPath = "tatort-dev/tatort" - def chartDir = "charts-tmp/${chartPath}" - def chartRepoRoot = "charts-tmp/tatort-dev" + branch: 'main' + ]) - sh """ - set -e - - echo "[INFO] Cloning chart repo..." - rm -rf charts-tmp - git clone ${chartRepo} charts-tmp - - echo "[INFO] Updating values.yaml and Chart.yaml..." - cd ${chartDir} - sed -i 's|^ repository: .*| repository: gitea.innovation-hub-niedersachsen.de/innohub/tatort-dev|' values.yaml - sed -i 's/^ tag: .*/ tag: ${newTag}/' values.yaml - sed -i 's/^version: .*/version: ${newTag}/' Chart.yaml - sed -i 's/^appVersion: .*/appVersion: ${newTag}/' Chart.yaml - - echo "[INFO] Cleaning up old chart packages..." - cd .. - rm -f index.yaml - rm -f tatort-*.tgz - git rm -f tatort-*.tgz || true - - echo "[INFO] Packaging Helm chart..." - cd tatort - helm package . --destination .. - - echo "[INFO] Updating Helm index.yaml..." - cd .. - helm repo index . --merge index.yaml || helm repo index . - - echo "[INFO] Committing and pushing chart changes..." - git config user.name "jenkins" - git config user.email "jenkins@innohub.local" - git add tatort/values.yaml tatort/Chart.yaml tatort-*.tgz index.yaml - git commit -m "ci: bump tatort-dev to ${newTag}, package chart + update index" - git push origin main - """ - } + didRun = true } } } From b2f624a7d14f3d3b3d47306b64d3730c87111a04 Mon Sep 17 00:00:00 2001 From: Daniel Mann Date: Wed, 16 Jul 2025 09:54:56 +0200 Subject: [PATCH 10/10] Update Jenkinsfile --- Jenkinsfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6001215..28cde92 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,8 @@ /* groovylint-disable-next-line UnusedVariable */ @Library('InnoHub-Library') _ -Boolean didRun = false +def didRun = false +def versionTag = 'null' pipeline { agent any @@ -11,7 +12,6 @@ pipeline { } environment { - VERSION_TAG = 'null' REGISTRY = 'https://gitea.innovation-hub-niedersachsen.de/' USER = 'jenkins' TOKEN = credentials('JenkinsGitea') @@ -35,8 +35,8 @@ pipeline { stage('Set Version Tag') { steps { script { - env.VERSION_TAG = generateVersionTag(params.GIT_REF) - echo "[INFO] Using VERSION_TAG: ${env.VERSION_TAG}" + versionTag = generateVersionTag(params.GIT_REF) + echo "[INFO] Using VERSION_TAG: ${versionTag}" } } } @@ -84,7 +84,7 @@ pipeline { def imageName = "gitea.innovation-hub-niedersachsen.de/innohub/tatort-dev" docker.withRegistry(REGISTRY, 'JenkinsGitea') { - def img = docker.build("${imageName}:${env.VERSION_TAG}", '-f Dockerfile.dev .') + def img = docker.build("${imageName}:${versionTag}", '-f Dockerfile.dev .') img.push() img.push('latest') } @@ -101,7 +101,7 @@ pipeline { steps { script { updateHelmChart([ - tag: env.VERSION_TAG, + tag: versionTag, repoUrl: 'gitea.innovation-hub-niedersachsen.de/innohub/charts.git', chartPath: 'tatort-dev/tatort', chartName: 'tatort',