-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile-Test.groovy
59 lines (53 loc) · 1.63 KB
/
Jenkinsfile-Test.groovy
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
pipeline {
environment {
registry = "wjloh91/jenkins-flask-redis"
registryCredential = 'wjloh_dockerhub_creds'
dockerImage = ''
}
agent any
stages {
stage('Cloning Git') {
steps {
git branch: 'develop', url: 'https://github.com/Physium/CICDChallenge.git'
}
}
stage('Build Image') {
steps {
script {
dockerImage = docker.build registry + ":$BUILD_NUMBER"
}
}
}
stage('Flask Unit Test') {
steps {
script {
dockerImage.inside {
sh 'python -m unittest tests/app_test.py'
}
}
}
}
stage('Push Image to Dockerhub') {
steps {
script {
docker.withRegistry( '',registryCredential ){
dockerImage.push()
}
}
}
}
stage('Clean up Image') {
steps {
sh "docker rmi $registry:$BUILD_NUMBER"
}
}
stage('Deploy Image to EKS') {
steps {
sh "kubectl config set-context --current --namespace=development"
sh "cat flask-redis-lb-deploy-template.yaml | sed \"s/{{IMAGE_TAG}}/$BUILD_NUMBER/g\" | kubectl apply -f -"
sh "sleep 10"
sh "kubectl get services -o=jsonpath=\"{.items[?(@.metadata.name=='counter-service')].status.loadBalancer.ingress[*].hostname}\""
}
}
}
}