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 {
|
environment {
|
||||||
|
VERSION_TAG = 'null'
|
||||||
REGISTRY = 'https://gitea.innovation-hub-niedersachsen.de/'
|
REGISTRY = 'https://gitea.innovation-hub-niedersachsen.de/'
|
||||||
USER = 'jenkins'
|
USER = 'jenkins'
|
||||||
TOKEN = credentials('JenkinsGitea')
|
TOKEN = credentials('JenkinsGitea')
|
||||||
@@ -31,6 +32,14 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
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') {
|
stage('Validate Repository') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
@@ -72,15 +81,15 @@ pipeline {
|
|||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
didRun = true
|
|
||||||
def versionTag = "0.${env.BUILD_ID}-dev.1"
|
|
||||||
def imageName = "gitea.innovation-hub-niedersachsen.de/innohub/tatort-dev"
|
def imageName = "gitea.innovation-hub-niedersachsen.de/innohub/tatort-dev"
|
||||||
|
|
||||||
docker.withRegistry('https://gitea.innovation-hub-niedersachsen.de', 'JenkinsGitea') {
|
docker.withRegistry(REGISTRY, 'JenkinsGitea') {
|
||||||
def img = docker.build("${imageName}:${versionTag}", '-f Dockerfile.dev .')
|
def img = docker.build("${imageName}:${env.VERSION_TAG}", '-f Dockerfile.dev .')
|
||||||
img.push()
|
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'
|
branch 'development'
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
withCredentials([
|
script {
|
||||||
usernamePassword(
|
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',
|
credentialsId: 'JenkinsGitea',
|
||||||
usernameVariable: 'GIT_USER',
|
branch: 'main'
|
||||||
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"
|
|
||||||
|
|
||||||
sh """
|
didRun = true
|
||||||
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
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user