-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
50 lines (50 loc) · 1.19 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
def label = "codeone-${UUID.randomUUID().toString()}"
podTemplate(name: 'codeone', label: label, yaml: """
kind: Pod
metadata:
name: codeone
spec:
containers:
- name: golang
image: golang:1.11-alpine
imagePullPolicy: Always
command:
- cat
tty: true
- name: kaniko
image: dcurrie/kaniko:alpine
imagePullPolicy: Always
command:
- cat
tty: true
volumeMounts:
- name: jenkins-docker-cfg
mountPath: /root
volumes:
- name: jenkins-docker-cfg
secret:
secretName: regcred
items:
- key: .dockerconfigjson
path: .docker/config.json
"""
) {
node(label) {
def commitId
stage ('Extract') {
commitId = checkout(scm).GIT_COMMIT.take(8)
}
stage ('Build') {
container ('golang') {
sh 'CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .'
}
}
def repository
stage ('Docker') {
container ('kaniko') {
repository = "index.docker.io/dcurrie/hello"
sh "executor -f `pwd`/Dockerfile -c `pwd` -d ${repository}:${commitId} --skip-tls-verify"
}
}
}
}