update: jenkinsfile code for multibranch pipeline
Employee App/pipeline/head This commit looks good
Details
Employee App/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b6150a7e32
commit
3cb374af92
|
|
@ -4,7 +4,7 @@ pipeline {
|
|||
environment {
|
||||
REGISTRY = "docker.io/adelyao"
|
||||
APP_NAME = "employee"
|
||||
MANIFEST_REPO = "https://git.winteraccess.id/adel/Employee-manifest.git"
|
||||
MANIFEST_REPO = "git.winteraccess.id/adel/Employee-manifest.git"
|
||||
MANIFEST_CRED_ID = "GIT_CRED_ID"
|
||||
DOCKER_CRED_ID = "DOCKER_CRED_ID"
|
||||
MANIFEST_DIR = "manifest"
|
||||
|
|
@ -73,8 +73,8 @@ pipeline {
|
|||
set -e
|
||||
rm -rf ${MANIFEST_DIR}-${overlayEnv}
|
||||
echo "Cloning manifest branch: ${overlayEnv}"
|
||||
git clone --single-branch --branch ${overlayEnv} https://\$GIT_USER:\$GIT_PASS@${env.MANIFEST_REPO.replace('https://', '')} ${MANIFEST_DIR}-${overlayEnv} || \
|
||||
(git clone https://\$GIT_USER:\$GIT_PASS@${env.MANIFEST_REPO.replace('https://', '')} ${MANIFEST_DIR}-${overlayEnv} && cd ${MANIFEST_DIR}-${overlayEnv} && git checkout -b ${overlayEnv})
|
||||
git clone --single-branch --branch ${overlayEnv} https://\$GIT_USER:\$GIT_PASS@${MANIFEST_REPO} ${MANIFEST_DIR}-${overlayEnv} || \
|
||||
(git clone https://\$GIT_USER:\$GIT_PASS@${MANIFEST_REPO} ${MANIFEST_DIR}-${overlayEnv} && cd ${MANIFEST_DIR}-${overlayEnv} && git checkout -b ${overlayEnv})
|
||||
"""
|
||||
|
||||
dir("${MANIFEST_DIR}-${overlayEnv}") {
|
||||
|
|
@ -83,7 +83,7 @@ pipeline {
|
|||
echo "Cleaning overlays folder (keeping only ${overlayEnv})..."
|
||||
for d in overlays/*; do
|
||||
[ -d "\$d" ] || continue
|
||||
if [ "\$(basename \"\$d\")" != "${overlayEnv}" ]; then
|
||||
if [ "\$(basename "\$d")" != "${overlayEnv}" ]; then
|
||||
echo "Removing \$d"
|
||||
rm -rf "\$d"
|
||||
fi
|
||||
|
|
@ -96,11 +96,14 @@ pipeline {
|
|||
git config user.email "jenkins@automation.local"
|
||||
git config user.name "Jenkins CI"
|
||||
|
||||
git add overlays/${overlayEnv}/patch-deployment.yaml
|
||||
echo "Staging all changes..."
|
||||
git add -A
|
||||
|
||||
echo "Committing changes..."
|
||||
git commit -m "chore(${overlayEnv}): update image tags to ${env.IMAGE_TAG_FINAL}" || echo "No changes to commit"
|
||||
|
||||
echo "Pushing updates to branch ${overlayEnv}"
|
||||
git push https://\$GIT_USER:\$GIT_PASS@${env.MANIFEST_REPO.replace('https://', '')} ${overlayEnv} || echo "No push needed for ${overlayEnv}"
|
||||
echo "Pushing updates to branch ${overlayEnv}..."
|
||||
git push https://\$GIT_USER:\$GIT_PASS@${MANIFEST_REPO} ${overlayEnv} || echo "No push needed for ${overlayEnv}"
|
||||
"""
|
||||
}
|
||||
|
||||
|
|
@ -129,4 +132,4 @@ pipeline {
|
|||
echo "Pipeline failed. Check logs for details."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue