Skip to content

Commit

Permalink
Merge pull request #286 from warrensbox/feature/add-fallback-option
Browse files Browse the repository at this point in the history
Feature/add fallback option
  • Loading branch information
warrensbox authored Feb 6, 2023
2 parents 5a95fbc + f1c77e1 commit d7dfd1b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ 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.
3. Hit **Enter** to install.
### 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 pipeline 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.
[Also, see CICD example](#cicd)

## Automation
**Automatically switch with bash**
Expand Down Expand Up @@ -244,7 +244,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 +264,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 +309,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
6 changes: 6 additions & 0 deletions www/docs/Continuous-Integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ 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 @@ -57,6 +60,9 @@ jobs:
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
```
5 changes: 5 additions & 0 deletions www/docs/Quick-Start.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,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 for CICD pipeline
1. When using a CICD pipeline, you may want a default or fallback version to avoid the pipeline 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.
[Also, see CICD example](../continuous-integration)

**Automatically switch with bash**

Add the following to the end of your `~/.bashrc` file:
Expand Down

0 comments on commit d7dfd1b

Please sign in to comment.