Files
my-app/Jenkinsfile

52 lines
1.4 KiB
Groovy

// Jenkinsfile
pipeline {
// Kubernetes Agent를 사용하여 파이프라인 실행
agent {
kubernetes {
// Kaniko 빌드를 위한 Pod 템플릿 정의
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:debug
command: ['sleep']
args: ['infinity']
volumeMounts:
- name: registry-credentials
mountPath: /kaniko/.docker
volumes:
- name: registry-credentials
secret:
secretName: registry-credentials
items:
- key: .dockerconfigjson
path: config.json
'''
}
}
stages {
stage('Checkout Source Code') {
steps {
// 5.3.2에서 생성한 Gitea 저장소에서 소스를 가져옵니다.
// Jenkins Credential에 Gitea 접근 정보를 미리 등록해야 합니다.
git branch: 'main', url: 'https://git.123.41.33.73.sslip.io/admin/my-app.git'
}
}
stage('Build and Push with Kaniko') {
steps {
// kaniko 컨테이너 내에서 이미지 빌드 및 푸시 명령을 실행합니다.
container(name: 'kaniko') {
sh '''
/kaniko/executor \\
--context=dir://. \\
--dockerfile=Dockerfile \\
--destination=hol3imgreg-eilodcty.scr.private.kr-west1.e.samsungsdscloud.com/web-app/my-app:2.0
'''
}
}
}
}
}