Skip to content

Commit 69941c7

Browse files
committed
Automation Toolkit Release v2024.2.2
1 parent 47e884c commit 69941c7

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

jenkins_install/tf-apply.groovy

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,26 @@ pipeline {
4545
// Assuming the job name format is <region_name>/job/<service_name>/job/job_name
4646
def regionName = parts[1]
4747
def serviceName = parts[2]
48-
4948
// Set environment variables for reuse in subsequent stages
5049
env.Region = regionName
5150
env.Service = serviceName
52-
53-
sh "cd \"${WORKSPACE}/${env.Region}/${env.Service}\" && terraform init -upgrade"
54-
55-
// Run Terraform plan and capture the output
56-
terraformPlanOutput = sh(script: "cd \"${WORKSPACE}/${env.Region}/${env.Service}\" && terraform plan -out=tfplan.out", returnStdout: true).trim()
57-
} else {
51+
} else {
5852
// Assuming the job name format is <region_name>/job/job_name
5953
def regionName = parts[1]
60-
54+
def serviceName = ''
55+
if (regionName == 'global') {
56+
serviceName = 'rpc'
57+
}
6158
// Set environment variables for reuse in subsequent stages
6259
env.Region = regionName
63-
sh "cd \"${WORKSPACE}/${env.Region}\" && terraform init -upgrade"
60+
env.Service = serviceName
61+
}
62+
63+
def final_path = "${WORKSPACE}/${env.Region}/${env.Service}"
64+
sh "cd \"${WORKSPACE}/${env.Region}/${env.Service}\" && terraform init -upgrade"
65+
// Run Terraform plan and capture the output
66+
terraformPlanOutput = sh(script: "cd \"${WORKSPACE}/${env.Region}/${env.Service}\" && terraform plan -out=tfplan.out", returnStdout: true).trim()
6467

65-
// Run Terraform plan and capture the output
66-
terraformPlanOutput = sh(script: "cd \"${WORKSPACE}/${env.Region}\" && terraform plan -out=tfplan.out", returnStdout: true).trim()
67-
}
6868

6969
// Check if the plan contains any changes
7070
if (terraformPlanOutput.contains('No changes.')) {

0 commit comments

Comments
 (0)