Created
June 27, 2019 18:01
-
-
Save khayyamsaleem/aa43d5c8de30d321e8ced03648da2167 to your computer and use it in GitHub Desktop.
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 any | |
stages { | |
stage('Checkout Source'){ | |
steps { | |
checkout scm | |
} | |
} | |
stage('Deploy') { | |
agent any | |
steps { | |
script { | |
if (BRANCH_NAME == 'master') { | |
sh 'docker stop $(docker ps -a | grep cxp-dashboard-prod | awk \'{ print $1 }\') || true' | |
sh 'docker rm $(docker ps -a | grep cxp-dashboard-prod | awk \'{ print $1 }\') || true' | |
sh 'docker rmi $(docker images | grep cxp-dashboard-prod | awk \'{ print $3 }\') || true' | |
sh 'docker-compose -f docker-compose.prod.yml up --build -d' | |
echo 'successfully deployed' | |
} else { | |
sh 'docker stop $(docker ps -a | grep cxp-dashboard-dev | awk \'{ print $1 }\') || true' | |
sh 'docker rm $(docker ps -a | grep cxp-dashboard-dev | awk \'{ print $1 }\') || true' | |
sh 'docker rmi $(docker images | grep cxp-dashboard-dev | awk \'{ print $3 }\') || true' | |
sh 'docker-compose -f docker-compose.dev.yml up --build -d' | |
echo 'successfully deployed dev version' | |
} | |
} | |
} | |
} | |
} | |
post { | |
failure { | |
script { | |
if (BRANCH_NAME == 'master'){ | |
echo 'no images currently built' | |
} else { | |
echo 'Something is wrong with develop???' | |
} | |
} | |
} | |
success { | |
script { | |
if (BRANCH_NAME == 'master'){ | |
echo 'ran tests successfully' | |
} else { | |
echo 'Develop is good to merge!' | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment