Skip to content

Commit

Permalink
Add default or fallback version for CICD pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
warrensbox committed Feb 6, 2023
1 parent 5a95fbc commit 8a7f5f5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down Expand Up @@ -244,7 +245,7 @@ function switch_terraform --on-event fish_postexec
end
end
```
## CICD
### Jenkins setup
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/jenkins_tfswitch.png" alt="drawing" style="width: 170px;"/>
Expand All @@ -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
```
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8a7f5f5

Please sign in to comment.