From 47d6d3da54dd2cc437c1efb5df89cdccdb0f3eb0 Mon Sep 17 00:00:00 2001 From: ptkimball Date: Thu, 8 Mar 2018 11:18:53 -0500 Subject: [PATCH] Add --auto-approve args to apply Fix for `terraform apply` defaulting to interactive mode. Started by user ptkimball [EnvInject] - Loading node environment variables. Building on master in workspace /var/lib/jenkins/workspace/Terraform PoC [terraform-plugin] $ /var/lib/jenkins/tools/org.jenkinsci.plugins.terraform.TerraformInstallation/Terraform_0.11.3/terraform get [terraform-plugin] $ /var/lib/jenkins/tools/org.jenkinsci.plugins.terraform.TerraformInstallation/Terraform_0.11.3/terraform apply -input=false "-state=/var/lib/jenkins/workspace/Terraform PoC/terraform-plugin/terraform-plugin.tfstate" An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: [32m+[0m create [0m Terraform will perform the following actions: [32m [32m+[0m [32maws_instance.example [0m id: ami: "ami-12345678" associate_public_ip_address: availability_zone: ebs_block_device.#: ephemeral_block_device.#: instance_state: instance_type: "t2.nano" ipv6_address_count: ipv6_addresses.#: key_name: network_interface.#: network_interface_id: placement_group: primary_network_interface_id: private_dns: private_ip: public_dns: public_ip: root_block_device.#: security_groups.#: source_dest_check: "true" subnet_id: "subnet-87654321" tenancy: volume_tags.%: vpc_security_group_ids.#: [0m [0m [0m[1mPlan:[0m 1 to add, 0 to change, 0 to destroy.[0m [0m[1mDo you want to perform these actions?[0m Terraform will perform the actions described above. Only 'yes' will be accepted to approve. [1mEnter a value:[0m [0m [31m [1m[31mError: [0m[0m[1mApply cancelled.[0m [0m[0m[0m FATAL: java.lang.Exception: Terraform Apply failed: 1 at org.jenkinsci.plugins.terraform.TerraformBuildWrapper.executeApply(TerraformBuildWrapper.java:249) at org.jenkinsci.plugins.terraform.TerraformBuildWrapper.setUp(TerraformBuildWrapper.java:269) at hudson.model.Build$BuildExecution.doRun(Build.java:157) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504) at hudson.model.Run.execute(Run.java:1724) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429) Finished: FAILURE --- .../org/jenkinsci/plugins/terraform/TerraformBuildWrapper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/jenkinsci/plugins/terraform/TerraformBuildWrapper.java b/src/main/java/org/jenkinsci/plugins/terraform/TerraformBuildWrapper.java index ecb67e0..c0bba9e 100644 --- a/src/main/java/org/jenkinsci/plugins/terraform/TerraformBuildWrapper.java +++ b/src/main/java/org/jenkinsci/plugins/terraform/TerraformBuildWrapper.java @@ -234,6 +234,7 @@ public void executeApply(AbstractBuild build, final Launcher launcher, final Bui args.add("apply"); args.add("-input=false"); + args.add("--auto-approve"); args.add("-state="+stateFile.getRemote()); if (!isNullOrEmpty(getVariables())) {