forked from cloudyuga/rsvpapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
45 lines (45 loc) · 991 Bytes
/
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
pipeline {
agent {
kubernetes {
label 'jenkins-slave'
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: dind
image: docker:18.09-dind
securityContext:
privileged: true
- name: docker
env:
- name: DOCKER_HOST
value: 127.0.0.1
image: docker:18.09
command:
- cat
tty: true
"""
}
}
environment {
IMAGE_REPO = "jawaharz/rsvpapp"
// Instead of Jawahars, use your git username
}
stages {
stage('Build') {
environment {
DOCKERHUB_CREDS = credentials('dockerhub')
}
steps {
container('docker') {
// Build new image
sh "until docker container ls; do sleep 3; done && docker image build -t ${env.IMAGE_REPO}:${env.GIT_COMMIT} ."
// Publish new image
sh "docker login --username $DOCKERHUB_CREDS_USR --password $DOCKERHUB_CREDS_PSW && docker image push ${env.IMAGE_REPO}:${env.GIT_COMMIT}"
}
}
}
}
}