From f60398750224ef07a3ce1412c0e17c19c0cc9eeb Mon Sep 17 00:00:00 2001 From: Syifa Date: Wed, 22 Oct 2025 09:17:42 +0700 Subject: [PATCH] add Jenkinsfile for pipeline gitops workflow --- Jenkinsfile | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d93be59..c31ace7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,6 +7,7 @@ pipeline { FRONTEND_NAME = "frontend-app" GITOPS_REPO = "https://git.winteraccess.id/syifa/datasiswa-gitops.git" GITOPS_BRANCH = "main" + DEPLOY_OVERLAY = "overlays/main" } stages { @@ -56,24 +57,6 @@ pipeline { } } - stage('Set Environment') { - steps { - script { - if (env.BRANCH_NAME == 'dev') { - env.DEPLOY_OVERLAY = 'overlays/dev' - } else if (env.BRANCH_NAME == 'staging') { - env.DEPLOY_OVERLAY = 'overlays/staging' - } else if (env.BRANCH_NAME == 'production') { - env.DEPLOY_OVERLAY = 'overlays/production' - } else { - error("Branch tidak dikenali! Harus dev / staging / production.") - } - - echo "Environment selected โ†’ ${env.DEPLOY_OVERLAY}" - } - } - } - stage('Update GitOps Repo') { steps { script { @@ -84,7 +67,7 @@ pipeline { git -c http.sslVerify=false clone -b $GITOPS_BRANCH https://$GITEA_USER:$GITEA_PASS@git.winteraccess.id/syifa/datasiswa-gitops.git gitops cd gitops - # Update tag image backend & frontend + # Update image tag di patch deployment sed -i "s|${REGISTRY}/${BACKEND_NAME}:[^ ]*|${BACKEND_TAG}|g" ${DEPLOY_OVERLAY}/patch-deployment.yaml sed -i "s|${REGISTRY}/${FRONTEND_NAME}:[^ ]*|${FRONTEND_TAG}|g" ${DEPLOY_OVERLAY}/patch-deployment.yaml @@ -102,14 +85,14 @@ pipeline { post { success { - echo "Deployment successful to ${DEPLOY_OVERLAY}" + echo "โœ… Deployment successful to ${DEPLOY_OVERLAY}" } failure { - echo "Deployment failed, check logs." + echo "โŒ Deployment failed, check logs." } always { cleanWs() - echo "Pipeline finished and workspace cleaned." + echo "๐Ÿงน Workspace cleaned." } } -} \ No newline at end of file +}