Skip to content

ConditionalApplyPlugin: Allow 'apply' on branches for specific environments #172

@boommies

Description

@boommies

Use Case:
I want to be able to apply changes to non-production environments, without merging to master.

Example: I have 3 environments:

  • qa
  • uat
  • prod

I want to be able to make a feature branch in git, and apply the changes from that branch to qa, before merging it into uat and prod.

Example Code:

@Library(['terraform-pipeline']) _

Jenkinsfile.init(this)

ConditionalApplyPlugin.withBranchApplyEnabledFor('qa').init()

def validate = new TerraformValidateStage()
def deployQa = new TerraformEnvironmentStage('qa')
def deployUat = new TerraformEnvironmentStage('uat')
def deployProd = new TerraformEnvironmentStage('prod')

validate.then(deployQa)
        .then(deployUat)
        .then(deployProd)
        .build()

Expected:

When I create a git branch and push a change, the pipeline will:

  1. Run a terraform plan for 'qa'
  2. Allow the user to apply the plan to 'qa'
  3. Run a plan for 'uat' (DOES NOT allow apply for 'uat')
  4. Run a plan for 'prod' (DOES NOT allow apply for 'uat')

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions