Skip to content

Instantly share code, notes, and snippets.

@shqear93
Last active October 5, 2020 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shqear93/46b68bc5080cffc9378de57aa40748e9 to your computer and use it in GitHub Desktop.
Save shqear93/46b68bc5080cffc9378de57aa40748e9 to your computer and use it in GitHub Desktop.
Jenkinsfile for Beanstalk Application
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