Skip to content

Commit 83486b5

Browse files
authored
Merge pull request #295 from bondezbond/master
added docs on withEnv & withGlobalEnv
2 parents 356fbd8 + 28f62cb commit 83486b5

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Unreleased
22

3+
* [Issue #293](https://github.com/manheim/terraform-pipeline/issues/293) withEnv & withGlobalEnv docs
4+
35
# v5.10
46

57
* [Issue #289](https://github.com/manheim/terraform-pipeline/issues/289) TagPlugin should work with both terraform 0.11.x and 0.12.x

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ Jenkinsfile.defaultNodeName = 'myNode'
205205

206206
Alternatively, you can assign all of your pipelines to a particular Jenkins slave label without using code, by setting a `DEFAULT_NODE_NAME` environment variable on your Jenkins master.
207207

208-
# Additional Pipeline Stages
208+
# Pipeline Stages
209209

210+
* [TerraformEnvironmentStage](./docs/TerraformEnvironmentStage.md) - run terraform plan & apply
210211
* [BuildStage](./docs/BuildStage.md) - build a deployment artifact that will subsequently be used by TerraformEnvironmentStage.
211212
* [RegressionStage](./docs/RegressionStage.md) - run automated tests against an environment
212213

docs/TerraformEnvironmentStage.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## [TerraformEnvironmentStage](../src/TerraformEnvironmentStage.groovy)
2+
3+
### Pass in Global Environment variable
4+
5+
You can pass in global environment variables too all stages in your pipeline using `withGlobalEnv`
6+
7+
```
8+
// Jenkinsfile
9+
@Library(['terraform-pipeline']) _
10+
11+
Jenkinsfile.init(this)
12+
13+
TerraformEnvironmentStage.withGlobalEnv('KEY_01', 'VALUE_01')
14+
.withGlobalEnv('KEY_01', 'VALUE_02')
15+
16+
def validate = new TerraformValidateStage()
17+
def deployQA = new TerraformEnvironmentStage('qa')
18+
def deployProd = new TerraformEnvironmentStage('prod')
19+
20+
validate.then(deployQA)
21+
.then(deployProd)
22+
.build()
23+
```
24+
25+
### Pass in Stage Specific Environment variable
26+
27+
You can pass in stage specific environment variables each stage in your pipeline using `withEnv`
28+
29+
```
30+
// Jenkinsfile
31+
@Library(['terraform-pipeline']) _
32+
33+
Jenkinsfile.init(this)
34+
35+
def validate = new TerraformValidateStage()
36+
def deployQA = new TerraformEnvironmentStage('qa').withEnv('KEY_01', 'VALUE_01')
37+
.withEnv('KEY_02', 'VALUE_02')
38+
def deployProd = new TerraformEnvironmentStage('prod').withEnv('KEY_03', 'VALUE_03')
39+
.withEnv('KEY_04', 'VALUE_04')
40+
41+
validate.then(deployQA)
42+
.then(deployProd)
43+
.build()
44+
```

0 commit comments

Comments
 (0)