TKK_E32222363/jenkinsfile

77 lines
1.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

pipeline {
agent {
kubernetes {
cloud 'kubernetes'
defaultContainer 'kaniko'
yaml """
apiVersion: v1
kind: Pod
metadata:
labels:
jenkins-job: kaniko-build
spec:
restartPolicy: Never
containers:
# ------------ 1) Kaniko (build & push) ------------
- name: kaniko
image: gcr.io/kaniko-project/executor:debug
command: ["/busybox/sh"]
args: ["-c", "sleep 3600"]
tty: true
env:
- name: DOCKER_CONFIG
value: /kaniko/.docker
volumeMounts:
- name: kaniko-secret
mountPath: /kaniko/.docker
# ------------ 2) Kubectl (deploy) ---------------
- name: kubectl
image: bitnami/kubectl:latest
command: ["sh", "-c", "sleep 3600"]
tty: true
volumes:
- name: kaniko-secret
secret:
secretName: regcred
"""
}
}
environment {
IMAGE = '10.10.3.232:5000/wordpress:latest'
GIT_CTX = 'git://github.com/RobbyDwiJayanto/rentalmotor.git#master'
}
stages {
stage('Build & Push Image') {
steps {
sh '''
/kaniko/executor \
--context=${GIT_CTX} \
--dockerfile=Dockerfile \
--destination=${IMAGE} \
--insecure \
--skip-tls-verify
'''
}
}
stage('Deploy to Cluster') {
steps {
container('kubectl') {
sh 'kubectl apply -f k8s/ -n jenkins'
}
}
}
}
post {
always { echo 'Pipeline selesai ✅' }
failure { echo '❌ Build gagal periksa log!' }
}
}