Skip to content

Instantly share code, notes, and snippets.

@jalogut
Last active June 8, 2018 14:12
Show Gist options
  • Save jalogut/a7d05c3326bc2dd2206ed269577d3b87 to your computer and use it in GitHub Desktop.
Save jalogut/a7d05c3326bc2dd2206ed269577d3b87 to your computer and use it in GitHub Desktop.
magento2-deployer-plus Jenkinsfild pipeline
node {
// Clean workspace before doing anything
deleteDir()
def hostStage
def deployStatus
try {
stage ('Preparations') {
if (BRANCH_NAME == 'develop') {
hostStage = 'dev'
}
if (BRANCH_NAME == 'stage') {
hostStage = 'stage'
}
if (BRANCH_NAME == 'master') {
hostStage = 'prod'
}
echo "Deploy to: ${hostStage}"
}
stage ('Clone') {
checkout scm
}
stage ('Composer') {
sh "composer install"
}
// stage ('Tests') {
// Out of scope of this gist
// }
stage ('Build') {
sh "vendor/bin/dep build -vvv"
}
if (hostStage) {
stage ("Deploy ${hostStage}") {
deployStatus = 'start'
sh "vendor/bin/dep deploy-artifact ${hostStage} -vvv"
deployStatus = 'finish'
}
} else {
stage ("Deploy Skipped") {
echo "Branch not valid for deployment: ${BRANCH_NAME}"
}
}
stage ('Clean Up') {
deleteDir()
}
} catch (err) {
if (deployStatus == 'start') {
stage ('Deploy Unlock') {
sh "vendor/bin/dep deploy:unlock ${hostStage} -vvv"
}
}
currentBuild.result = 'FAILED'
throw err
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment