데브코스 TIL - 젠킨슨 파이프라인 만들기 1
젠킨슨 파이프라인 만들기
1. 새로운 아이템 만들기
- name: simple-echo-2
- pipeline
2. 아이템 기본 설정하기
Pipeline 스크립트 작성
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
pipeline{
environment {
dockerImageName = "hyeem66/simple-echo"
}
agent any
stages{
stage('git scm update'){
steps{
sh "git clone https://github.com/hyemin12/pl-exp.git ."
}
}
stage('docker build && push'){
steps {
script {
dockerImage = docker.build dockerImageName
docker.withRegistry('https://registry.hub.docker.com',
'dockerhub-credentials') {
dockerImage.push('latest')
}
}
}
}
stage('deploy application on kubernetes cluster'){
steps{
withKubeConfig([credentialId: 'KUBECONFIG',
serverUrl: 'https://kubernetes.default',
namespace:'default']){
sh '''
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
'''
}
}
}
}
post {
always {
sh 'docker logout'
}
}
}
3. 빌드해보면 실패됨
1
agent any
부분을 다음과 같이 수정
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
agent {
kubernetes{
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: jnlp
image: sheayun/jnlp-agent-sample
env:
- name: DOCKER_HOST
value: "tcp://localhost:2375"
- name: dind
image: docker:latest
command:
- /usr/local/bin/dockerd-entrypoint.sh
env:
- name: DOCKER_TLS_CERTDIR
value: ""
securityContext:
privileged: true
'''
}
}
This post is licensed under CC BY 4.0 by the author.