Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

* [Issue #293](https://github.com/manheim/terraform-pipeline/issues/293) withEnv & withGlobalEnv docs

# v5.10

* [Issue #289](https://github.com/manheim/terraform-pipeline/issues/289) TagPlugin should work with both terraform 0.11.x and 0.12.x
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ Jenkinsfile.defaultNodeName = 'myNode'

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.

# Additional Pipeline Stages
# Pipeline Stages

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

Expand Down
44 changes: 44 additions & 0 deletions docs/TerraformEnvironmentStage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## [TerraformEnvironmentStage](../src/TerraformEnvironmentStage.groovy)

### Pass in Global Environment variable

You can pass in global environment variables too all stages in your pipeline using `withGlobalEnv`

```
// Jenkinsfile
@Library(['terraform-pipeline']) _

Jenkinsfile.init(this)

TerraformEnvironmentStage.withGlobalEnv('KEY_01', 'VALUE_01')
.withGlobalEnv('KEY_01', 'VALUE_02')

def validate = new TerraformValidateStage()
def deployQA = new TerraformEnvironmentStage('qa')
def deployProd = new TerraformEnvironmentStage('prod')

validate.then(deployQA)
.then(deployProd)
.build()
```

### Pass in Stage Specific Environment variable

You can pass in stage specific environment variables each stage in your pipeline using `withEnv`

```
// Jenkinsfile
@Library(['terraform-pipeline']) _

Jenkinsfile.init(this)

def validate = new TerraformValidateStage()
def deployQA = new TerraformEnvironmentStage('qa').withEnv('KEY_01', 'VALUE_01')
.withEnv('KEY_02', 'VALUE_02')
def deployProd = new TerraformEnvironmentStage('prod').withEnv('KEY_03', 'VALUE_03')
.withEnv('KEY_04', 'VALUE_04')

validate.then(deployQA)
.then(deployProd)
.build()
```