GithubPRPlanPlugin.md
August 4, 2020 ยท View on GitHub
GithubPRPlanPlugin
Use this to post Terraform plan results in the comments of a PR.
One-Time Setup:
- Your pipeline should be configured as a Multibranch Pipeline with Github Repository HTTPS URL.
- Create a Github Personal Access Token that has permission to comment on your repo. By default, the a Github Personal Access Token is expected to be available in an environment variable
GITHUB_TOKEN. A number of credential and configuration management plugins are available to do this. Optionally, your Github Authentication token can be assigned to a different environment variable using.withGithubTokenEnvVar(<different variable>)
@Library(['terraform-pipeline']) _
Jenkinsfile.init(this)
// A GITHUB_TOKEN environment variable should contain your Github PAT
GithubPRPlanPlugin.init()
// After creating a PullRequest, the plan results for each
// environment are posted as a comment to the PullRequest.
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()
Changing Repo Host
By default, this plugin will examime the SCM URL configured for a given pipeline to determine how to post comments.
If you wish to change the repo host url, use the withRepoHost() option.
Example:
...
// Change the repo host
GithubPRPlanPlugin.withRepoHost("https://mygithubenterprise.company.com")
.init()
...
~``