-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
68 lines (68 loc) · 1.48 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
62
63
64
65
66
67
68
pipeline {
agent any
environment {
ACR_PASS = credentials('ACR_PASS')
}
stages {
stage('build dev') {
steps {
sh '''
echo "building development docker container image"
docker build -t chyld/calc -f Dockerfile.dev .
'''
}
}
stage('test') {
steps {
sh '''
echo "running rspec tests"
docker run --rm chyld/calc rspec
'''
}
}
stage('build prod') {
steps {
sh '''
echo "building production docker container image"
docker build -t azurechyld.azurecr.io/calc:v$BUILD_NUMBER -f Dockerfile.prod .
'''
}
}
stage('registry login') {
steps {
sh '''
echo "login to azure container registry"
docker login --username=azurechyld --password=$ACR_PASS azurechyld.azurecr.io
'''
}
}
stage('registry push') {
steps {
sh '''
echo "push production docker container image to azure registry"
docker push azurechyld.azurecr.io/calc:v$BUILD_NUMBER
'''
}
}
stage('deploy k8s') {
steps {
sh '''
echo "deploy kubernetes to azure"
envsubst < deployment.yaml | kubectl apply -f -
'''
}
}
}
post {
always {
echo "pruning docker images from system"
sh '''docker system prune -f'''
}
success {
echo "success"
}
failure {
echo "failure!"
}
}
}