Compare commits
10 Commits
49a60993b4
...
a5f17567ee
| Author | SHA1 | Date |
|---|---|---|
|
|
a5f17567ee | |
|
|
02a77c976c | |
|
|
e6b1fb6128 | |
|
|
d8bb9c04a8 | |
|
|
53e1e741e9 | |
|
|
f72b956ef2 | |
|
|
3d0085f982 | |
|
|
585651f460 | |
|
|
2adc220615 | |
|
|
1b8797929e |
110
JENKINSFILE
110
JENKINSFILE
|
|
@ -42,8 +42,8 @@
|
||||||
environment {
|
environment {
|
||||||
//ProxySettings
|
//ProxySettings
|
||||||
AUTH = credentials('proxy')
|
AUTH = credentials('proxy')
|
||||||
proxy_user = "${AUTH_USR}"
|
proxy_user = '${AUTH_USR}'
|
||||||
proxy_pw = "${AUTH_PSW}"
|
proxy_pw = '${AUTH_PSW}'
|
||||||
//http_proxy="http://${proxy_user}:${proxy_pw}@proxy.muc:8080"
|
//http_proxy="http://${proxy_user}:${proxy_pw}@proxy.muc:8080"
|
||||||
//https_proxy="http://${proxy_user}:${proxy_pw}@proxy.muc:8080"
|
//https_proxy="http://${proxy_user}:${proxy_pw}@proxy.muc:8080"
|
||||||
//no_proxy="localhost,127.0.0.1,.muc,.bmwgroup.net"
|
//no_proxy="localhost,127.0.0.1,.muc,.bmwgroup.net"
|
||||||
|
|
@ -81,11 +81,11 @@
|
||||||
TF_VAR_NA_PREPROD_API_TOKEN=credentials('NAPREPROD_TOKEN_VAR')
|
TF_VAR_NA_PREPROD_API_TOKEN=credentials('NAPREPROD_TOKEN_VAR')
|
||||||
|
|
||||||
//CN PROD
|
//CN PROD
|
||||||
TF_VAR_CN_PROD_ENV_URL="https://dyna-synth-cn.bmwgroup.com.cn/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b"
|
TF_VAR_CN_PROD_ENV_URL="https://dynatrace-cn-int.bmwgroup.com/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b"
|
||||||
TF_VAR_CN_PROD_API_TOKEN=credentials('CNPROD_TOKEN_VAR')
|
TF_VAR_CN_PROD_API_TOKEN=credentials('CNPROD_TOKEN_VAR')
|
||||||
|
|
||||||
//CN PREPROD
|
//CN PREPROD
|
||||||
TF_VAR_CN_PREPROD_ENV_URL="https://dyna-synth-cn.bmwgroup.com.cn/e/ab88c03b-b7fc-45f0-9115-9e9ecc0ced35"
|
TF_VAR_CN_PREPROD_ENV_URL="https://dynatrace-cn-int.bmwgroup.com/e/ab88c03b-b7fc-45f0-9115-9e9ecc0ced35"
|
||||||
TF_VAR_CN_PREPROD_API_TOKEN=credentials('CNPREPROD_TOKEN_VAR')
|
TF_VAR_CN_PREPROD_API_TOKEN=credentials('CNPREPROD_TOKEN_VAR')
|
||||||
|
|
||||||
//TERRAFORM
|
//TERRAFORM
|
||||||
|
|
@ -101,22 +101,14 @@
|
||||||
git branch: '${branch}', credentialsId: 'jaws_dynatrace_bitbuket_user', url: 'https://atc.bmwgroup.net/bitbucket/scm/opapm/coco_terraform_config.git'
|
git branch: '${branch}', credentialsId: 'jaws_dynatrace_bitbuket_user', url: 'https://atc.bmwgroup.net/bitbucket/scm/opapm/coco_terraform_config.git'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
stage('install required python packages') {
|
|
||||||
steps {
|
|
||||||
sh '''
|
|
||||||
pip3 install --user -r requirements.txt
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
stage('Install Terraform') {
|
stage('Install Terraform') {
|
||||||
steps {
|
steps {
|
||||||
sh '''
|
sh '''
|
||||||
cd /tmp
|
cd /tmp
|
||||||
curl https://releases.hashicorp.com/terraform/1.1.6/terraform_1.1.6_linux_amd64.zip > terraform.zip
|
curl https://releases.hashicorp.com/terraform/1.1.6/terraform_1.1.6_linux_amd64.zip > terraform.zip
|
||||||
unzip terraform.zip
|
yes | sudo unzip terraform.zip
|
||||||
sudo mv /tmp/terraform /usr/local/bin
|
yes | sudo mv -f /tmp/terraform /usr/local/bin
|
||||||
sudo chmod +x /usr/local/bin/terraform
|
sudo chmod +x /usr/local/bin/terraform
|
||||||
terraform --version
|
terraform --version
|
||||||
cd ~
|
cd ~
|
||||||
|
|
@ -149,20 +141,15 @@
|
||||||
if(folderArr != null){
|
if(folderArr != null){
|
||||||
for (folder in folderArr)
|
for (folder in folderArr)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
sh """
|
|
||||||
cd $WORKSPACE
|
|
||||||
cd $WORKSPACE/$environment/$folder
|
|
||||||
"""
|
|
||||||
*/
|
|
||||||
init_status = sh(returnStatus: true, script: "cd $WORKSPACE/$environment/$folder && set +e; terraform init")
|
init_status = sh(returnStatus: true, script: "cd $WORKSPACE/$environment/$folder && set +e; terraform init")
|
||||||
if (init_status == 0) {
|
if (init_status == 0) {
|
||||||
println "Starting terraform plan..."
|
println "Starting terraform plan..."
|
||||||
plan_status = sh(returnStatus: true, script: "cd $WORKSPACE/$environment/$folder && set +e; terraform plan -out=tfplan -detailed-exitcode")
|
plan_status = sh(returnStatus: true, script: "cd $WORKSPACE/$environment/$folder && set +e; terraform plan -out=tfplan -detailed-exitcode")
|
||||||
if (plan_status != 0) {
|
if (plan_status == 1) {
|
||||||
println "Failed to plan $folder for $environment"
|
println "Failed to plan $folder for $environment"
|
||||||
sh("curl -H 'Content-Type: application/json' -d '{\"text\":\"Failed to plan $folder for ${environment}\"}' https://bmwgroup.webhook.office.com/webhookb2/483edc00-c925-4672-8088-8299a0139fca@ce849bab-cc1c-465b-b62e-18f07c9ac198/JenkinsCI/1cf354c0e2e54e2baaf2f20b051b1dda/af36b177-c3fb-4707-a2d4-c75dbce454a2")
|
sh("curl -H 'Content-Type: application/json' -d '{\"text\":\"Failed to plan $folder for ${environment}\"}' https://bmwgroup.webhook.office.com/webhookb2/483edc00-c925-4672-8088-8299a0139fca@ce849bab-cc1c-465b-b62e-18f07c9ac198/JenkinsCI/1cf354c0e2e54e2baaf2f20b051b1dda/af36b177-c3fb-4707-a2d4-c75dbce454a2")
|
||||||
currentBuild.result = 'UNSTABLE'}
|
currentBuild.result = 'UNSTABLE'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
println "Failed to init $folder for $environment"
|
println "Failed to init $folder for $environment"
|
||||||
|
|
@ -177,16 +164,20 @@
|
||||||
if(folderArr != null){
|
if(folderArr != null){
|
||||||
for (folder in folderArr)
|
for (folder in folderArr)
|
||||||
{
|
{
|
||||||
sh """
|
init_status = sh(returnStatus: true, script: "cd $WORKSPACE/$environment/$folder && set +e; terraform init")
|
||||||
cd $WORKSPACE
|
if (init_status == 0) {
|
||||||
cd $environment/$folder
|
println "Starting terraform plan..."
|
||||||
"""
|
plan_status = sh(returnStatus: true, script: "cd $WORKSPACE/$environment/$folder && set +e; terraform plan -out=tfplan -detailed-exitcode")
|
||||||
status = sh(returnStatus: true, script: "set +e; terraform init")
|
println "Statuscode: $plan_status"
|
||||||
if (status == "0") {
|
if (plan_status == 1) {
|
||||||
status = sh(returnStatus: true, script: "set +e; terraform plan -out=tfplan -detailed-exitcode")
|
println "Failed to plan $folder for $environment"
|
||||||
if (status != "0") {currentBuild.result = 'UNSTABLE'}
|
sh("curl -H 'Content-Type: application/json' -d '{\"text\":\"Failed to plan $folder for ${environment}\"}' https://bmwgroup.webhook.office.com/webhookb2/483edc00-c925-4672-8088-8299a0139fca@ce849bab-cc1c-465b-b62e-18f07c9ac198/JenkinsCI/1cf354c0e2e54e2baaf2f20b051b1dda/af36b177-c3fb-4707-a2d4-c75dbce454a2")
|
||||||
|
currentBuild.result = 'UNSTABLE'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
println "Failed to init $folder for $environment"
|
||||||
|
sh("curl -H 'Content-Type: application/json' -d '{\"text\":\"Failed to init $folder for ${environment}\"}' https://bmwgroup.webhook.office.com/webhookb2/483edc00-c925-4672-8088-8299a0139fca@ce849bab-cc1c-465b-b62e-18f07c9ac198/JenkinsCI/1cf354c0e2e54e2baaf2f20b051b1dda/af36b177-c3fb-4707-a2d4-c75dbce454a2")
|
||||||
currentBuild.result = 'UNSTABLE'
|
currentBuild.result = 'UNSTABLE'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -203,31 +194,39 @@
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
ArrayList folderArr = evaluate("${CONFIGS}")
|
ArrayList folderArr = evaluate("${CONFIGS}")
|
||||||
if(ENVIRONMENT != 'ALL'){
|
if(ENVIRONMENT != 'ALL')
|
||||||
if(folderArr != null){
|
{
|
||||||
|
if(folderArr != null)
|
||||||
|
{
|
||||||
for (folder in folderArr)
|
for (folder in folderArr)
|
||||||
{
|
{
|
||||||
sh """
|
apply_status = sh(returnStatus: true, script: "cd $WORKSPACE/$environment/$folder && set +e; terraform apply tfplan")
|
||||||
cd $WORKSPACE
|
if (apply_status != 0)
|
||||||
cd $ENVIRONMENT/$folder
|
{
|
||||||
set +e; terraform apply tfplan
|
println "Failed to apply $folder for $environment"
|
||||||
"""
|
sh("curl -H 'Content-Type: application/json' -d '{\"text\":\"Failed to apply $folder for ${environment}\"}' https://bmwgroup.webhook.office.com/webhookb2/483edc00-c925-4672-8088-8299a0139fca@ce849bab-cc1c-465b-b62e-18f07c9ac198/JenkinsCI/1cf354c0e2e54e2baaf2f20b051b1dda/af36b177-c3fb-4707-a2d4-c75dbce454a2")
|
||||||
|
currentBuild.result = 'UNSTABLE'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
for (environment in environments){
|
for (environment in environments)
|
||||||
if(folderArr != null){
|
{
|
||||||
|
if(folderArr != null)
|
||||||
|
{
|
||||||
for (folder in folderArr)
|
for (folder in folderArr)
|
||||||
{
|
{
|
||||||
sh """
|
// apply_status = sh(returnStatus: true, script: "cd $WORKSPACE/$environment/$folder && set +e; terraform plan -out=tfplan -detailed-exitcode")
|
||||||
cd $WORKSPACE
|
apply_status = sh(returnStatus: true, script: "cd $WORKSPACE/$environment/$folder && set +e; terraform apply tfplan")
|
||||||
cd $environment/$folder
|
if (apply_status != 0)
|
||||||
terraform apply tfplan
|
{
|
||||||
"""
|
println "Failed to apply $folder for $environment"
|
||||||
|
sh("curl -H 'Content-Type: application/json' -d '{\"text\":\"Failed to apply $folder for ${environment}\"}' https://bmwgroup.webhook.office.com/webhookb2/483edc00-c925-4672-8088-8299a0139fca@ce849bab-cc1c-465b-b62e-18f07c9ac198/JenkinsCI/1cf354c0e2e54e2baaf2f20b051b1dda/af36b177-c3fb-4707-a2d4-c75dbce454a2")
|
||||||
|
currentBuild.result = 'UNSTABLE'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -235,21 +234,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
stage('Execute Export Script TERRAFORM') {
|
|
||||||
steps {
|
|
||||||
|
|
||||||
export_config_all(environments)
|
|
||||||
//sh 'python3 export.py EMEA_PROD'
|
|
||||||
//sh 'python3 export.py TERRAFORM'
|
|
||||||
|
|
||||||
//Only required once CN is not reachable from EMEA
|
|
||||||
//loopEnvironments(environments)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
stage('Send report') {
|
stage('Send report') {
|
||||||
|
|
@ -258,7 +242,7 @@
|
||||||
try {
|
try {
|
||||||
emailext subject: env.JOB_NAME,
|
emailext subject: env.JOB_NAME,
|
||||||
body: 'Please find the output of your reports attached',
|
body: 'Please find the output of your reports attached',
|
||||||
to: 'rene.forstner@nttdata.com',
|
to: 'bmw.dynatrace@nttdata.com',
|
||||||
replyTo: 'coco-apm@bmw.de',
|
replyTo: 'coco-apm@bmw.de',
|
||||||
attachmentsPattern: '*.csv'
|
attachmentsPattern: '*.csv'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue