Created
January 10, 2020 09:09
-
-
Save kathisai/19e305b5857ffefab7610f74d3efc682 to your computer and use it in GitHub Desktop.
JenkinsFile for docker image build and Kubernetes
This file contains hidden or 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
| pipeline { | |
| agent { | |
| label 'reactapp-node' // This is my slave node machine I want to run this pipeline on my slave agent | |
| } | |
| stages { | |
| /* see # https://gist.github.com/nicferrier/2277987 for automating clone + pull */ | |
| stage('Cloneing deployments') { | |
| steps { | |
| echo 'Cloneing && pulling....' | |
| bat 'cd deployment && git pull origin' | |
| } | |
| } | |
| //see https://github.com/javahometech/node-app/blob/master/Jenkinsfile for reference set up | |
| stage('Build') { | |
| steps { | |
| bat "docker build --no-cache . -t react-image:v.${BUILD_NUMBER}" | |
| } | |
| } | |
| // see https://code-maze.com/ci-jenkins-docker/ for build number | |
| stage('Publish') { | |
| steps { | |
| echo 'Publishing....' | |
| bat "docker tag react-image:v.${BUILD_NUMBER} react-image:v.${BUILD_NUMBER}" | |
| bat "docker push react-image:v.${BUILD_NUMBER}" | |
| } | |
| } | |
| stage('Deployment') { | |
| steps { | |
| echo 'Deployinging....' | |
| bat ' kubectl delete -f react-test.yaml' | |
| bat ' kubectl apply -f react-test.yaml' | |
| } | |
| } | |
| } | |
| post { | |
| always { | |
| echo 'Portal image is deployed in to Kubernetes ' | |
| } | |
| success { | |
| echo 'Successfully!' | |
| } | |
| failure { | |
| echo 'Failed!' | |
| } | |
| unstable { | |
| echo 'This will run only if the run was marked as unstable' | |
| } | |
| changed { | |
| echo 'This will run only if the state of the Pipeline has changed' | |
| echo 'For example, if the Pipeline was previously failing but is now successful' | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment