Skip to content

Instantly share code, notes, and snippets.

@jan-koch
Last active September 12, 2019 05:08
Show Gist options
  • Save jan-koch/8f9ea98c2fc294c34429ef4a6fdd5b6a to your computer and use it in GitHub Desktop.
Save jan-koch/8f9ea98c2fc294c34429ef4a6fdd5b6a to your computer and use it in GitHub Desktop.
Jenkinsfile for automated deployment with Github and PHPloy
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