From 8a7f5f5a7b5a6745da79d4664863359b60d0c29d Mon Sep 17 00:00:00 2001 From: "warren.veerasingam@gmail.com" Date: Sun, 5 Feb 2023 17:08:10 -0800 Subject: [PATCH] Add default or fallback version for CICD pipelines --- README.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3f444481..1c000856 100644 --- a/README.md +++ b/README.md @@ -169,10 +169,11 @@ tfswitch -c terraform_dir To install from a remote mirror other than the default(https://releases.hashicorp.com/terraform). Use the `-m` or `--mirror` parameter. Ex: `tfswitch --mirror https://example.jfrog.io/artifactory/hashicorp` -### Set a default TF version to pick -1. Help the CI systems to default to a version in case version is not detected from above steps. -2. Ex: `tfswitch -d 1.2.3` or `tfswitch --default 1.2.3` installs version `1.2.3` in case no other versions could be detected. +### Set a default TF version for CICD pipeline +1. When using a CICD pipeline, you may want a default or fallback version to avoid the pipe from hanging. +2. Ex: `tfswitch -d 1.2.3` or `tfswitch --default 1.2.3` installs version `1.2.3` when no other versions could be detected. 3. Hit **Enter** to install. +[Also, see CICD example](#cicd) ## Automation **Automatically switch with bash** @@ -244,7 +245,7 @@ function switch_terraform --on-event fish_postexec end end ``` - +## CICD ### Jenkins setup drawing @@ -264,6 +265,10 @@ export PATH=$PATH:$CUSTOMBIN #Add custom bin path to PATH environment $CUSTOMBIN/tfswitch -b $CUSTOMBIN/terraform 0.11.7 #or simply tfswitch -b $CUSTOMBIN/terraform 0.11.7 +#OR + +$CUSTOMBIN/tfswitch -d 0.11.7 -b $CUSTOMBIN/terraform #or simply tfswitch -d 0.11.7 -b $CUSTOMBIN/terraform + terraform -v #testing version ``` @@ -305,6 +310,9 @@ jobs: $CUSTOMBIN/tfswitch -b $CUSTOMBIN/terraform 0.11.7 #or simply tfswitch -b $CUSTOMBIN/terraform 0.11.7 + #OR + $CUSTOMBIN/tfswitch -d 0.11.7 -b $CUSTOMBIN/terraform #or simply tfswitch -d 0.11.7 -b $CUSTOMBIN/terraform + terraform -v #testing version ``` ## Order of precedence