forked from learnk8s/docker-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
61 lines (56 loc) · 1.42 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
podTemplate(label: 'docker-build',
containers: [
containerTemplate(
name: 'git',
image: 'alpine/git',
command: 'cat',
ttyEnabled: true
),
containerTemplate(
name: 'docker',
image: 'docker',
command: 'cat',
ttyEnabled: true
),
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
]
) {
node('docker-build') {
def dockerHubCred = docker-hub
def appImage
stage('Checkout'){
container('git'){
checkout scm
}
}
stage('Build'){
container('docker'){
script {
appImage = docker.build("minseok1001/node-hello-world")
}
}
}
stage('Test'){
container('docker'){
script {
appImage.inside {
sh 'npm install'
sh 'npm test'
}
}
}
}
stage('Push'){
container('docker'){
script {
docker.withRegistry('https://registry.hub.docker.com', dockerHubCred){
appImage.push("${env.BUILD_NUMBER}")
appImage.push("latest")
}
}
}
}
}
}