-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
62 lines (59 loc) · 1.73 KB
/
Copy pathJenkinsfile
File metadata and controls
62 lines (59 loc) · 1.73 KB
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
pipeline {
agent any
stages {
stage ('Ready') {
steps {
sh '''
echo "Ready to build pipeline."
echo "Build ID: ${BUILD_ID}"
'''
}
}
stage ('Lint') {
steps {
sh '''
echo "Lint Dockerfile"
dockerlint Dockerfile
'''
}
}
stage ('Docker Build & Push') {
steps {
script {
docker.withRegistry('https://registry.hub.docker.com', 'dockerhub') {
def app = docker.build("devinyang1992/udacityclouddevopsnanodegree:latest", '.')
app.push()
}
}
}
}
stage ('Green deployment') {
steps {
script {
withAWS(credentials: 'aws-credentials', region: 'us-west-2'){
sh "aws eks update-kubeconfig --region us-west-2 --name udacitycluster"
sh 'kubectl apply -f deploy/green.yml'
}
}
}
}
stage ('Blue deployment') {
steps {
script {
withAWS(credentials: 'aws-credentials', region: 'us-west-2'){
sh 'kubectl apply -f deploy/blue.yml'
sh 'echo "Blue deployment successfully"'
}
}
}
}
stage ('Finish & Clean Up') {
steps {
sh '''
echo 'Cleaning up...'
docker system prune
'''
}
}
}
}