-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5f8f16
commit aa6f9a8
Showing
1 changed file
with
100 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,100 @@ | ||
pipeline { | ||
agent any | ||
stages { | ||
stage('list repo contents and working directory') { | ||
steps { | ||
script { | ||
sh "ls" | ||
sh "pwd" | ||
sh "whoami" | ||
} | ||
} | ||
} | ||
stage('create build') { | ||
steps { | ||
script { | ||
sh "./gradlew clean build" | ||
} | ||
} | ||
} | ||
stage('list the created build file') { | ||
steps { | ||
script { | ||
sh "ls build/libs/" | ||
} | ||
} | ||
} | ||
stage('Remove old jar from DOCKER') { | ||
steps { | ||
script { | ||
sh "sudo rm DOCKER/spring-boot-with-prometheus-0.1.0.jar" | ||
} | ||
} | ||
} | ||
stage('copy jar to DOCKER') { | ||
steps { | ||
script { | ||
sh "sudo cp build/libs/spring-boot-with-prometheus-0.1.0.jar DOCKER/" | ||
} | ||
} | ||
} | ||
stage('building docker image') { | ||
steps { | ||
script { | ||
sh "cd DOCKER; sudo docker build -t rajchauhan9/microk8s-kubernetes-poc:v_${BUILD_NUMBER} ." | ||
} | ||
} | ||
} | ||
stage('dcoker push') { | ||
steps { | ||
script { | ||
sh "sudo docker push rajchauhan9/microk8s-kubernetes-poc:v_${BUILD_NUMBER}" | ||
} | ||
} | ||
} | ||
stage('deploying on kubernetes') { | ||
steps { | ||
script { | ||
sh "kubectl set image deployment.apps/rajeev-deployment rajeev=rajchauhan9/microk8s-kubernetes-poc:v_${BUILD_NUMBER}" | ||
sh "kubectl rollout status deployment.apps/rajeev-deployment" | ||
} | ||
} | ||
} | ||
stage ('remove images from build server') { | ||
steps { | ||
script { | ||
try { | ||
sh "sudo docker images -a -q > images_cid; sudo docker rmi `cat images_cid`" | ||
} catch (err) { | ||
echo err.getMessage() | ||
} | ||
} | ||
echo currentBuild.result | ||
} | ||
} | ||
stage ('rollback') { | ||
steps { | ||
sh ''' | ||
if [ $rollback == true ]; | ||
then | ||
kubectl set image deployment.apps/rajeev-deployment rajeev=rajchauhan9/microk8s-kubernetes-poc:v_${OLD_BUILD_NUMBER} | ||
kubectl rollout status deployment.apps/rajeev-deployment | ||
else | ||
echo "parameter not selected" | ||
''' | ||
} | ||
} | ||
// stage('remove unused images') { | ||
// steps { | ||
// script { | ||
// try { | ||
// sh "sudo docker rmi `cat unused_images_cid`" | ||
// } catch (err) { | ||
// echo err.getMessage() | ||
// } | ||
// } | ||
// echo currentBuild.result | ||
// } | ||
// } | ||
} | ||
} | ||
// pipeline { | ||
// agent any | ||
// stages { | ||
// stage('list repo contents and working directory') { | ||
// steps { | ||
// script { | ||
// sh "ls" | ||
// sh "pwd" | ||
// sh "whoami" | ||
// } | ||
// } | ||
// } | ||
// stage('create build') { | ||
// steps { | ||
// script { | ||
// sh "./gradlew clean build" | ||
// } | ||
// } | ||
// } | ||
// stage('list the created build file') { | ||
// steps { | ||
// script { | ||
// sh "ls build/libs/" | ||
// } | ||
// } | ||
// } | ||
// stage('Remove old jar from DOCKER') { | ||
// steps { | ||
// script { | ||
// sh "sudo rm DOCKER/spring-boot-with-prometheus-0.1.0.jar" | ||
// } | ||
// } | ||
// } | ||
// stage('copy jar to DOCKER') { | ||
// steps { | ||
// script { | ||
// sh "sudo cp build/libs/spring-boot-with-prometheus-0.1.0.jar DOCKER/" | ||
// } | ||
// } | ||
// } | ||
// stage('building docker image') { | ||
// steps { | ||
// script { | ||
// sh "cd DOCKER; sudo docker build -t rajchauhan9/microk8s-kubernetes-poc:v_${BUILD_NUMBER} ." | ||
// } | ||
// } | ||
// } | ||
// stage('dcoker push') { | ||
// steps { | ||
// script { | ||
// sh "sudo docker push rajchauhan9/microk8s-kubernetes-poc:v_${BUILD_NUMBER}" | ||
// } | ||
// } | ||
// } | ||
// stage('deploying on kubernetes') { | ||
// steps { | ||
// script { | ||
// sh "kubectl set image deployment.apps/rajeev-deployment rajeev=rajchauhan9/microk8s-kubernetes-poc:v_${BUILD_NUMBER}" | ||
// sh "kubectl rollout status deployment.apps/rajeev-deployment" | ||
// } | ||
// } | ||
// } | ||
// stage ('remove images from build server') { | ||
// steps { | ||
// script { | ||
// try { | ||
// sh "sudo docker images -a -q > images_cid; sudo docker rmi `cat images_cid`" | ||
// } catch (err) { | ||
// echo err.getMessage() | ||
// } | ||
// } | ||
// echo currentBuild.result | ||
// } | ||
// } | ||
// stage ('rollback') { | ||
// steps { | ||
// sh ''' | ||
// if [ $rollback == true ]; | ||
// then | ||
// kubectl set image deployment.apps/rajeev-deployment rajeev=rajchauhan9/microk8s-kubernetes-poc:v_${OLD_BUILD_NUMBER} | ||
// kubectl rollout status deployment.apps/rajeev-deployment | ||
// else | ||
// echo "parameter not selected" | ||
// ''' | ||
// } | ||
// } | ||
// // stage('remove unused images') { | ||
// // steps { | ||
// // script { | ||
// // try { | ||
// // sh "sudo docker rmi `cat unused_images_cid`" | ||
// // } catch (err) { | ||
// // echo err.getMessage() | ||
// // } | ||
// // } | ||
// // echo currentBuild.result | ||
// // } | ||
// // } | ||
// } | ||
// } |