wip - jenkins de merde.
parent
736fdb87af
commit
0c65c5897c
|
|
@ -1,8 +1,8 @@
|
||||||
String cloud_provider = "aws"
|
String cloud_provider = "aws"
|
||||||
String aws_region = "eu-west-1"
|
String aws_region = "eu-west-1"
|
||||||
String stage = "int"
|
String default_stage = "int"
|
||||||
String aws_access_credentials = "fdc_$aws_region_$stage_infrastructure.automation.user"
|
String aws_access_credentials = "fdc_${aws_region}_${default_stage}_infrastructure.automation.user"
|
||||||
String dynatrace_api_toke_credentials = "api_token_dynatrace_$aws_region_$stage"
|
String dynatrace_api_token_credentials = "api_token_dynatrace_${aws_region}_${default_stage}"
|
||||||
|
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
|
|
@ -20,10 +20,10 @@ pipeline {
|
||||||
AWS_SECRET_ACCESS_KEY = "${env.AWS_ID_PSW}"
|
AWS_SECRET_ACCESS_KEY = "${env.AWS_ID_PSW}"
|
||||||
|
|
||||||
AWS_REGION = "${aws_region}"
|
AWS_REGION = "${aws_region}"
|
||||||
STAGE = "${stage}"
|
STAGE = "${default_stage}"
|
||||||
CLOUD_PROVIDER = "${cloud_provider}"
|
CLOUD_PROVIDER = "${cloud_provider}"
|
||||||
|
|
||||||
API_TOKEN = credentials("${dynatrace_api_toke_credentials}")
|
API_TOKEN = credentials("${dynatrace_api_token_credentials}")
|
||||||
TF_VAR_dt_api_token = "${env.API_TOKEN}"
|
TF_VAR_dt_api_token = "${env.API_TOKEN}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,6 +50,57 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage('Terraform plan') {
|
||||||
|
steps {
|
||||||
|
sshagent(credentials: ['sofa-user-automation']) {
|
||||||
|
container('terraform') {
|
||||||
|
script {
|
||||||
|
|
||||||
|
sh "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} "
|
||||||
|
env.PLAN_STATUS = sh(script: "terraform plan -out=.terraform/plan.out -input=false -detailed-exitcode", returnStatus: true)
|
||||||
|
if (env.PLAN_STATUS == "1") {
|
||||||
|
currentBuild.result = "FAILURE"
|
||||||
|
error('Aborting the build.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Interactive') {
|
||||||
|
when {
|
||||||
|
allOf {
|
||||||
|
expression { env.PLAN_STATUS == "2" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
timeout(time: 15, unit: "MINUTES") {
|
||||||
|
input "Is this plan acceptable?"
|
||||||
|
milestone 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage("terraform apply") {
|
||||||
|
when {
|
||||||
|
allOf {
|
||||||
|
expression { env.PLAN_STATUS == "2" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
container('terraform') {
|
||||||
|
sshagent(credentials: ['sofa-user-automation']) {
|
||||||
|
script {
|
||||||
|
sh "cd environments/${CLOUD_PROVIDER}/${AWS_REGION}/${STAGE} "
|
||||||
|
sh("terraform apply -input=false .terraform/plan.out")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue