-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJenkinsfile
130 lines (124 loc) · 2.97 KB
/
Jenkinsfile
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
pipeline {
agent any
stages {
stage ('Clone') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [], submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/devops-ws/learn-pipeline-go']]]
)
}
}
stage ('Build Code') {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: golang
image: "registry.cn-beijing.aliyuncs.com/surenpi/golang:1.15.5"
command:
- cat
tty: true
'''
label 'golang'
}
}
steps {
container ('golang') {
sh label: 'Build Go Source Code', script: 'make build'
}
}
}
stage ('Build Image') {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
metadata:
labels:
app: helm-push
spec:
volumes:
- hostPathVolume:
hostPath: "/var/run/docker.sock"
mountPath: "/var/run/docker.sock"
containers:
- name: docker
image: registry.cn-beijing.aliyuncs.com/surenpi/golang:1.15.5
command:
- cat
tty: true
'''
label 'golang'
}
}
steps {
container ('docker') {
sh label: 'Build Image', script: 'make image'
}
}
}
stage ('Charts Package') {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
metadata:
spec:
containers:
- name: helm
image: alpine/helm:3.4.1
command:
- cat
tty: true
'''
label 'helm'
}
}
steps {
container ('helm') {
sh label: 'Charts Package', script: 'helm package go-server-charts'
}
}
}
stage ('Charts Upload') {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
app: helm-push
spec:
containers:
- name: helm
image: surenpi/helm-push:v0.0.1
command:
- cat
tty: true
'''
label 'helm-push'
}
}
steps {
container ('helm') {
sh label: 'Charts Upload', script: '''
helm push mychart/ http://localhost:8080
'''
/**
# Or you can use the curl command directly
sh label: 'Charts Upload', script: '''
curl -L --data-binary "@go-server-0.1.0.tgz" http://localhost:8080/api/charts
'''
*/
}
}
}
}
}