forked from ciberado/pokemon-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
45 lines (45 loc) · 1.26 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
podTemplate(
label: 'jenkinspod',
inheritFrom: 'default',
containers: [
containerTemplate(
name: 'docker',
image: 'docker:18.02',
ttyEnabled: true,
command: 'cat'
)
],
volumes: [
hostPathVolume(
hostPath: '/var/run/docker.sock',
mountPath: '/var/run/docker.sock'
)
]
) {
node('jenkinspod') {
def commitId
stage ('Extract') {
checkout scm
commitId = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
}
def repository
stage ('Build') {
container ('docker') {
repository = "ciberado/pokemon-nodejs"
sh "docker build -t ${repository}:${commitId} ."
}
}
stage("push") {
container ('docker') {
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'docker_hub',
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD'
]]) {
sh "docker login -u $USERNAME -p $PASSWORD"
sh "docker push ${repository}:${commitId}"
}
}
}
}
}