Update Jenkinsfile
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
This commit is contained in:
77
Jenkinsfile
vendored
77
Jenkinsfile
vendored
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user