-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
40 lines (40 loc) · 1.2 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
def label = "codeone-${UUID.randomUUID().toString()}"
podTemplate(
name: 'codeone',
label: label,
inheritFrom: 'default',
containers: [
containerTemplate(
name: 'golang',
image: 'golang:1.11-alpine',
ttyEnabled: true,
command: 'cat'
),
containerTemplate(
name: 'kaniko',
image: 'dcurrie/kaniko:alpine',
ttyEnabled: true,
command: 'cat'
)
]
) {
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') {
def registryIp = sh(script: 'getent hosts registry.kube-system | awk \'{ print $1 ; exit }\'', returnStdout: true).trim()
repository = "${registryIp}:80/hello"
sh "executor -f `pwd`/Dockerfile -c `pwd` -d ${repository}:${commitId} --skip-tls-verify --insecure"
}
}
}
}