-
-
Save shqear93/46b68bc5080cffc9378de57aa40748e9 to your computer and use it in GitHub Desktop.
Jenkinsfile for Beanstalk Application
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 | |
options { skipDefaultCheckout() } | |
environment { | |
AWS_DEFAULT_REGION = 'eu-west-1' | |
} | |
stages { | |
stage('Prepare') { | |
agent any | |
steps { | |
script { | |
switch(BRANCH_NAME) { | |
case 'master': | |
EB_APPLICATION = 'MyApp' | |
EB_ENVIRONMENT = 'MyApp-production' | |
TRIGGER_TEST = false | |
break; | |
case 'uat': | |
EB_APPLICATION = 'MyApp' | |
EB_ENVIRONMENT = 'MyApp-uat' | |
TRIGGER_TEST = false | |
break; | |
case 'sandbox': | |
EB_APPLICATION = 'MyApp' | |
EB_ENVIRONMENT = 'MyApp-sandbox' | |
TRIGGER_TEST = false | |
break; | |
default: | |
EB_APPLICATION = 'MyApp' | |
EB_ENVIRONMENT = 'MyApp-testing' | |
TRIGGER_TEST = true | |
} | |
echo "Application selected: ${EB_APPLICATION}" | |
echo "Environment selected: ${EB_ENVIRONMENT}" | |
} | |
} | |
} | |
stage('Deploy') { | |
agent { | |
docker { | |
image 'coxauto/aws-ebcli:latest' | |
} | |
} | |
steps { | |
checkout scm | |
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', | |
credentialsId: 'my-app-deploy']]) { | |
sh "printf '\n\n\n\n\n' | eb init ${EB_APPLICATION} --region ${AWS_DEFAULT_REGION}" | |
sh "eb deploy --verbose -l \$(git rev-parse HEAD) ${EB_ENVIRONMENT}" | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment