Last active
September 12, 2019 05:08
-
-
Save jan-koch/8f9ea98c2fc294c34429ef4a6fdd5b6a to your computer and use it in GitHub Desktop.
Jenkinsfile for automated deployment with Github and PHPloy
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
pipeline { | |
agent any | |
// Pull the repo first. | |
stages { | |
stage( 'Checkout Repo' ) { | |
steps { | |
checkout scm | |
} | |
} | |
stage( 'Deploy' ) { | |
steps { | |
// Run git status just to log anything outstanding. | |
sh 'git status' | |
script{ | |
switch( env.BRANCH_NAME ) { | |
case "master": | |
// Comment out the next line if the target directory | |
// does not exist on the server. | |
sh 'vendor/bin/phploy --list -s production' | |
sh 'vendor/bin/phploy -s production --force' | |
break | |
case "staging": | |
// Comment out the next line if the target directory | |
// does not exist on the server. | |
sh 'vendor/bin/phploy --list -s staging' | |
sh 'vendor/bin/phploy -s staging --force' | |
break | |
default: | |
// Doing nothing | |
break | |
} | |
} | |
} | |
} | |
} | |
// Run items after pipeline completion/failure | |
post { | |
always { | |
// Always clearn up the directory, regardless. | |
deleteDir() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment