Skip to content

Commit 7ba4b8f

Browse files
committed
Add PLAN_ONLY parameter
1 parent 520ce89 commit 7ba4b8f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/PlanOnlyPlugin.groovy

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ class PlanOnlyPlugin implements TerraformEnvironmentStagePlugin, TerraformPlanCo
66
public static void init() {
77
PlanOnlyPlugin plugin = new PlanOnlyPlugin()
88

9+
BuildWithParametersPlugin.withBooleanParameter([
10+
name: "PLAN_ONLY",
11+
description: 'Run `terraform plan` only, skipping `terraform apply`.'
12+
])
13+
914
BuildWithParametersPlugin.withBooleanParameter([
1015
name: "FAIL_PLAN_ON_CHANGES",
1116
description: 'Plan run with -detailed-exitcode; ANY CHANGES will cause failure'
@@ -23,8 +28,10 @@ class PlanOnlyPlugin implements TerraformEnvironmentStagePlugin, TerraformPlanCo
2328

2429
@Override
2530
public void apply(TerraformEnvironmentStage stage) {
26-
stage.decorateAround(CONFIRM, skipStage(CONFIRM))
27-
stage.decorateAround(APPLY, skipStage(APPLY))
31+
if (Jenkinsfile.instance.getEnv().PLAN_ONLY == 'true') {
32+
stage.decorateAround(CONFIRM, skipStage(CONFIRM))
33+
stage.decorateAround(APPLY, skipStage(APPLY))
34+
}
2835
}
2936

3037
@Override

0 commit comments

Comments
 (0)