fix: checkout application repo stage
This commit is contained in:
parent
cf45ceb5b0
commit
dee7e6b12b
|
|
@ -5,7 +5,6 @@ pipeline {
|
||||||
REGISTRY = "docker.io/adelyao"
|
REGISTRY = "docker.io/adelyao"
|
||||||
APP_NAME = "employee"
|
APP_NAME = "employee"
|
||||||
MANIFEST_REPO = "https://git.winteraccess.id/adel/Employee-manifest.git"
|
MANIFEST_REPO = "https://git.winteraccess.id/adel/Employee-manifest.git"
|
||||||
APP_REPO = "https://git.winteraccess.id/adel/Employee-app.git"
|
|
||||||
MANIFEST_CRED_ID = "GIT_CRED_ID"
|
MANIFEST_CRED_ID = "GIT_CRED_ID"
|
||||||
DOCKER_CRED_ID = "DOCKER_CRED_ID"
|
DOCKER_CRED_ID = "DOCKER_CRED_ID"
|
||||||
BRANCH = "main"
|
BRANCH = "main"
|
||||||
|
|
@ -17,9 +16,10 @@ pipeline {
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
|
|
||||||
stage('Clean Workspace') {
|
stage('Prepare Workspace') {
|
||||||
steps {
|
steps {
|
||||||
cleanWs()
|
cleanWs()
|
||||||
|
checkout scm // ✅ otomatis clone repo Gitea tempat Jenkinsfile berada
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,19 +38,8 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Checkout Application Repo') {
|
stage('Build and Push Docker Images') {
|
||||||
steps {
|
steps {
|
||||||
dir('app') {
|
|
||||||
git branch: env.BRANCH,
|
|
||||||
url: env.APP_REPO,
|
|
||||||
credentialsId: env.MANIFEST_CRED_ID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Build and Push Docker Image') {
|
|
||||||
steps {
|
|
||||||
dir('app') {
|
|
||||||
script {
|
script {
|
||||||
def tag = params.IMAGE_TAG ?: "build-${env.BUILD_NUMBER}"
|
def tag = params.IMAGE_TAG ?: "build-${env.BUILD_NUMBER}"
|
||||||
echo "Building and pushing image with tag: ${tag}"
|
echo "Building and pushing image with tag: ${tag}"
|
||||||
|
|
@ -70,14 +59,16 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
stage('Checkout Manifest Repo') {
|
stage('Checkout Manifest Repo') {
|
||||||
steps {
|
steps {
|
||||||
dir('manifest') {
|
dir('manifest') {
|
||||||
checkout([$class: 'GitSCM',
|
checkout([$class: 'GitSCM',
|
||||||
branches: [[name: env.BRANCH]],
|
branches: [[name: env.BRANCH]],
|
||||||
userRemoteConfigs: [[url: env.MANIFEST_REPO, credentialsId: env.MANIFEST_CRED_ID]]
|
userRemoteConfigs: [[
|
||||||
|
url: env.MANIFEST_REPO,
|
||||||
|
credentialsId: env.MANIFEST_CRED_ID
|
||||||
|
]]
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -108,7 +99,7 @@ pipeline {
|
||||||
git add -A
|
git add -A
|
||||||
git diff --staged --quiet || (git commit -m "chore: update image to ${env.IMAGE_TAG_FINAL}" && git push https://${GIT_USER}:${GIT_PASS}@${env.MANIFEST_REPO.replace('https://', '')} ${env.BRANCH})
|
git diff --staged --quiet || (git commit -m "chore: update image to ${env.IMAGE_TAG_FINAL}" && git push https://${GIT_USER}:${GIT_PASS}@${env.MANIFEST_REPO.replace('https://', '')} ${env.BRANCH})
|
||||||
"""
|
"""
|
||||||
echo "Manifest repo updated successfully"
|
echo "✅ Manifest repo updated successfully"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -123,10 +114,10 @@ pipeline {
|
||||||
|
|
||||||
post {
|
post {
|
||||||
success {
|
success {
|
||||||
echo "GitOps pipeline completed successfully!"
|
echo "🎉 GitOps pipeline completed successfully!"
|
||||||
}
|
}
|
||||||
failure {
|
failure {
|
||||||
echo "Pipeline failed. Check previous logs."
|
echo "❌ Pipeline failed. Check previous logs."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue