add Jenkinsfile for pipeline gitops workflow
This commit is contained in:
parent
a16a141798
commit
f603987502
|
|
@ -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."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue