Skip to content

Instantly share code, notes, and snippets.

@caiges
Last active December 28, 2018 06:24
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 caiges/92d60439dda8ad24f99e1b0fad5262ca to your computer and use it in GitHub Desktop.
Save caiges/92d60439dda8ad24f99e1b0fad5262ca to your computer and use it in GitHub Desktop.
pipeline {
agent { label 'infrastructure-deployer' }
parameters {
string(name: 'ENV', description: 'The environment to deploy')
string(name: 'TERRAFORM_BRANCH', defaultValue: 'master', description: 'The infrastructure branch to deploy')
}
stages {
stage('clone infrastructure') {
steps {
checkout poll: false, scm: [$class: 'GitSCM',
branches: [[name: "*/${params.TERRAFORM_BRANCH}"]],
extensions: [[$class: 'RelativeTargetDirectory',
relativeTargetDir: 'infrastructure']],
userRemoteConfigs: [[credentialsId: 'somecreds', url: 'ssh://git@github.com:someorg/infrastructure.git']]]
}
}
stage('build terraform image') {
steps {
dir('bold-infrastructure/') {
sh 'make image'
}
}
}
stage('fetch secrets') {
steps{
dir('bold-infrastructure') {
sh 'aws s3 cp s3://somebucket/somesecret somesecret'
}
}
}
stage('build environment') {
steps {
dir('bold-infrastructure') {
sh 'make init'
sh "ENV=${params.ENV} make workspace"
sh "ENV=${params.ENV} make apply"
}
script {
api_host = sh(returnStdout: true, script: "jq -r '.api_host.value' outputs.json").trim()
}
slackSend (color: '#FFFF00', message: "Deploy API HOST: ${api_host})")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment