From 82233538d36c884ec98aa2074de8043e9b6cd82b Mon Sep 17 00:00:00 2001 From: Vivian Oloruntoba <112525771+voloruntoba@users.noreply.github.com> Date: Sat, 18 Feb 2023 21:37:27 -0700 Subject: [PATCH 1/5] Create Jenkinsfile --- Jenkinsfile | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..9484610 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,79 @@ +pipeline { + agent any + +stages { + stage('Gitclone') { + steps { + sh 'git clone https://github.com/voloruntoba/Google-Kubernetes-boilerplate.git' + } + } + stage('Build & Push') { + steps { + withCredentials([usernamePassword(credentialsId: 'dockercred', passwordVariable: 'dockerpass', usernameVariable: 'dockeruser')]) { + sh 'cd Google-Kubernetes-boilerplate/app/adservice && docker build -t adservice .' + sh 'docker login -u $dockeruser -p $dockerpass' + sh 'docker tag adservice $dockeruser/adservice:latest' + sh 'docker push $dockeruser/adservice:latest' + sh 'cd . && cd Google-Kubernetes-boilerplate/app/cartservice/src/ && docker build -t cartservice .' + sh 'docker login -u $dockeruser -p $dockerpass' + sh 'docker tag cartservice $dockeruser/cartservice:latest' + sh 'docker push $dockeruser/cartservice:latest' + sh 'cd . && cd Google-Kubernetes-boilerplate/app/cartservice/src/ && docker build -t cartservice .' + sh 'docker login -u $dockeruser -p $dockerpass' + sh 'docker tag cartservice $dockeruser/cartservice:latest' + sh 'docker push $dockeruser/cartservice:latest' + sh 'cd . && cd Google-Kubernetes-boilerplate/app/checkoutservice/ && docker build -t checkoutservice .' + sh 'docker login -u $dockeruser -p $dockerpass' + sh 'docker tag checkoutservice $dockeruser/checkoutservice:latest' + sh 'docker push $dockeruser/checkoutservice:latest' + //remove all images + sh 'docker rmi -f $(docker images -aq) && docker system prune -f' + // + sh 'cd . && cd Google-Kubernetes-boilerplate/app/currencyservice/ && docker build -t currencyservice .' + sh 'docker login -u $dockeruser -p $dockerpass' + sh 'docker tag currencyservice $dockeruser/currencyservice:latest' + sh 'docker push $dockeruser/currencyservice:latest' + sh 'cd . && cd Google-Kubernetes-boilerplate/app/emailservice/ && docker build -t emailservice .' + sh 'docker login -u $dockeruser -p $dockerpass' + sh 'docker tag emailservice $dockeruser/emailservice:latest' + sh 'docker push $dockeruser/emailservice:latest' + //remove all images + sh 'docker rmi -f $(docker images -aq) && docker system prune -f' + // + sh 'cd . && cd Google-Kubernetes-boilerplate/app/frontend/ && docker build -t frontend .' + sh 'docker login -u $dockeruser -p $dockerpass' + sh 'docker tag frontend $dockeruser/frontend:latest' + sh 'docker push $dockeruser/frontend:latest' + sh 'cd . && cd Google-Kubernetes-boilerplate/app/loadgenerator/ && docker build -t loadgenerator .' + sh 'docker login -u $dockeruser -p $dockerpass' + sh 'docker tag loadgenerator $dockeruser/loadgenerator:latest' + sh 'docker push $dockeruser/loadgenerator:latest' + //remove all images + sh 'docker rmi -f $(docker images -aq) && docker system prune -f' + // + sh 'cd . && cd Google-Kubernetes-boilerplate/app/paymentservice/ && docker build -t paymentservice .' + sh 'docker login -u $dockeruser -p $dockerpass' + sh 'docker tag paymentservice $dockeruser/paymentservice:latest' + sh 'docker push $dockeruser/paymentservice:latest' + sh 'cd . && cd Google-Kubernetes-boilerplate/app/productcatalogservice/ && docker build -t productcatalogservice .' + sh 'docker login -u $dockeruser -p $dockerpass' + sh 'docker tag productcatalogservice $dockeruser/productcatalogservice:latest' + sh 'docker push $dockeruser/productcatalogservice:latest' + sh 'cd . && cd Google-Kubernetes-boilerplate/app/recommendationservice/ && docker build -t recommendationservice .' + sh 'docker login -u $dockeruser -p $dockerpass' + sh 'docker tag recommendationservice $dockeruser/recommendationservice:latest' + sh 'docker push $dockeruser/recommendationservice:latest' + sh 'cd . && cd Google-Kubernetes-boilerplate/app/shippingservice/ && docker build -t shippingservice .' + sh 'docker login -u $dockeruser -p $dockerpass' + sh 'docker tag shippingservice $dockeruser/shippingservice:latest' + sh 'docker push $dockeruser/shippingservice:latest' + //remove all images + sh 'docker rmi -f $(docker images -aq) && docker system prune -f' + //remove git hub repo + sh 'cd ../../../' + sh 'rm -rf Google-Kubernetes-boilerplate' + } + } + } + } + } From 48fa52e5078383f5505503f7e8160dcaa956a7b1 Mon Sep 17 00:00:00 2001 From: Vivian Oloruntoba <112525771+voloruntoba@users.noreply.github.com> Date: Sat, 18 Feb 2023 21:42:08 -0700 Subject: [PATCH 2/5] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 9484610..5687f2a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -77,3 +77,4 @@ stages { } } } + From 27c68680eee45164908ef7150aa590633dc54e6c Mon Sep 17 00:00:00 2001 From: Vivian Oloruntoba <112525771+voloruntoba@users.noreply.github.com> Date: Sat, 18 Feb 2023 21:42:58 -0700 Subject: [PATCH 3/5] Update Jenkinsfile update --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5687f2a..95b434c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -77,4 +77,5 @@ stages { } } } - + + From 048fcff18d4e20e3dc276c9aa11a5a6aa2b191f4 Mon Sep 17 00:00:00 2001 From: Vivian Oloruntoba <112525771+voloruntoba@users.noreply.github.com> Date: Sat, 18 Feb 2023 22:16:14 -0700 Subject: [PATCH 4/5] Update Jenkinsfile --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 95b434c..5e7279a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -78,4 +78,3 @@ stages { } } - From 07f35d50f7775f6dd8106696b441bb659dba0442 Mon Sep 17 00:00:00 2001 From: Vivian Oloruntoba <112525771+voloruntoba@users.noreply.github.com> Date: Sat, 18 Feb 2023 22:18:50 -0700 Subject: [PATCH 5/5] Update Jenkinsfile