Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Jenkinsfile #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
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'
}
}
}
}
}