-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
54 lines (52 loc) · 1.95 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
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'echo Building...'
}
}
stage('Lint HTML') {
steps {
sh 'tidy -q -e *.html'
}
}
stage('Create kube config file') {
steps {
withAWS(region: 'ap-south-1', credentials: 'aws'){
sh '''
aws eks --region ap-south-1 update-kubeconfig --name mycapstone
'''
}
}
}
stage('Build Docker Image') {
steps {
sh 'docker build -t udacity-capstone-app .'
}
}
stage('Push Docker Image') {
steps {
withDockerRegistry([url: "", credentialsId: "dockerhub"]) {
sh "docker tag udacity-capstone-app mydocker49/udacity-capstone-app"
sh 'docker push mydocker49/udacity-capstone-app'
}
}
}
stage('Deploying') {
steps{
echo 'Deploying to AWS...'
withAWS(credentials: 'aws', region: 'ap-south-1') {
sh "aws eks --region ap-south-1 update-kubeconfig --name mycapstone"
sh "kubectl config use-context arn:aws:eks:ap-south-1:527375347403:cluster/mycapstone"
sh "kubectl apply -f deployment/deployment.yml"
sh "kubectl get nodes"
sh "kubectl get deployment"
sh "kubectl get pod -o wide"
sh "kubectl get service/udacity-cloud-devops-capstone"
sh "kubectl set image deployments/udacity-cloud-devops-capstone udacity-cloud-devops-capstone=mydocker49/udacity-cloud-devops-capstone:latest"
}
}
}
}
}