-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
86 lines (75 loc) · 2.36 KB
/
Jenkinsfile
File metadata and controls
86 lines (75 loc) · 2.36 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
pipeline{
agent{
label 'docker-worker'
}
environment{
DOCKER_REPO="docuser200"
APP_IMAGE_NAME="python-webapp:${BUILD_NUMBER}.0.0"
DOCKERHUB_REGISTRY="https://index.docker.io/v1/"
}
stages{
stage('Build application image'){
steps{
// withDockerRegistry([url: "http://${NEXUS_RAW_RELEASE_REPO}", credentialsId: "8258d105-ddf8-43bc-8714-00718fe2cedc"]){
sh '''
docker build -t ${DOCKER_REPO}/${APP_IMAGE_NAME} -f Dockerfile .
'''
// }
}
}
stage('Push image to Application Repo'){
steps{
withDockerRegistry([url: "${DOCKERHUB_REGISTRY}", credentialsId: "fb81a327-08b9-43f6-9e8e-95d99d7d01ed"]){
sh '''
docker push ${DOCKER_REPO}/${APP_IMAGE_NAME}
'''
}
}
}
stage('Update image name in yaml'){
steps{
sh'''
sed -i "s/IMAGE_NAME/${DOCKER_REPO}\\/${APP_IMAGE_NAME}/g" kubernetes/python-webapp-deployment.yaml
cat kubernetes/python-webapp-deployment.yaml
'''
}
}
stage('Deploy Application to minikube'){
steps{
sh'''
#Create config file
mkdir ~/.kube
echo 'apiVersion: v1
clusters:
- cluster:
certificate-authority: /home/.minikube/ca.crt
server: https://192.168.99.100:8443
name: minikube
contexts:
- context:
cluster: minikube
user: minikube
name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
user:
client-certificate: /home/.minikube/client.crt
client-key: /home/.minikube/client.key' > ~/.kube/config
# apply yaml file
kubectl apply -f kubernetes/python-redis-deployment.yaml
kubectl apply -f kubernetes/python-webapp-deployment.yaml
'''
}
}
stage('Cleanup images from host') {
steps {
sh'''
docker rmi ${DOCKER_REPO}/${APP_IMAGE_NAME}
'''
}
}
}
}