Skip to content

Commit cfbebd3

Browse files
authored
Merge pull request #434 from duckpuppy/change_master_to_main
Fixes #372 - Change default branch from `master` to `main`
2 parents 20765fb + f7da68d commit cfbebd3

14 files changed

+53
-38
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ build
55
.idea
66
*.iml
77
/out
8+
.history
9+
tags
10+
.vscode
11+
shell.nix
12+
nix/

CHANGELOG.md

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

3+
- [Issue #372](https://github.com/manheim/terraform-pipeline/issues/372) Replace `master` branch with `main` in documentation
4+
- [Issue #372](https://github.com/manheim/terraform-pipeline/issues/372)
5+
ConditionalApplyPlugin: Support main and master branches
6+
- [Issue #372](https://github.com/manheim/terraform-pipeline/issues/372)
7+
TerraformTaintPlugin: Support main and master branches
38
- [Issue #432](https://github.com/manheim/terraform-pipeline/issues/432) pass TagPlugin through `-var-file={env}-tags.tfvars`
49
- [Issue #417](https://github.com/manheim/terraform-pipeline/issues/417) DestroyPlugin & PassPlanFilePlugin - Terraform Destroy can't be called with a plan file
510

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A reusable pipeline template to apply terraform configuration serially across mu
99
2. `terraform plan`
1010
3. `terraform apply`
1111
2. After running a terraform plan, your pipeline will pause. A human must review and confirm the plan before `terraform apply` is run. See: [ConfirmApplyPlugin](./docs/ConfirmApplyPlugin.md).
12-
3. When running your pipeline on a branch, only the `terraform init` and `terraform plan` commands will be run across all of your environments. `terraform apply` is only made available on the master branch. See: [ConditionalApplyPlugin](./docs/ConditionalApplyPlugin.md).
12+
3. When running your pipeline on a branch, only the `terraform init` and `terraform plan` commands will be run across all of your environments. `terraform apply` is only made available on the main branch. See: [ConditionalApplyPlugin](./docs/ConditionalApplyPlugin.md).
1313
4. If your environments might create conflicting resources, a TF_VAR_environment variable is automatically available to your project and can be used to namespace your resources and avoid conflicts. See: [DefaultEnvironmentPlugin](./docs/DefaultEnvironmentPlugin.md).
1414
5. Import terraform-pipeline as a Jenkinsfile library to your Jenkins instance.
1515
![Importing Pipeline Library](./images/import-terraform-pipeline.png)
@@ -95,7 +95,7 @@ The example above gives you a bare-bones pipeline, and there may be Jenkinsfile
9595
### Default Plugins
9696
* [BuildWithParametersPlugin](./docs/BuildWithParametersPlugin.md): use this plugin to manage the "Build with Parameters" feature of pipelines.
9797
* [ConfirmApplyPlugin](./docs/ConfirmApplyPlugin.md): pause and review the plan, before applying any changes.
98-
* [ConditionalApplyPlugin](./docs/ConditionalApplyPlugin.md): only allow apply on master branch.
98+
* [ConditionalApplyPlugin](./docs/ConditionalApplyPlugin.md): only allow apply on main branch.
9999
* [DefaultEnvironmentPlugin](./docs/DefaultEnvironmentPlugin.md): automatically set `TF_VAR_environment` variable.
100100
* [TerraformPlugin](./docs/TerraformPlugin.md): apply version-specific terraform behavior based on the version of terraform in use.
101101
### Credentials and Configuration Management
@@ -208,7 +208,7 @@ By default, the pipeline jobs are not assigned to a particular Jenkins slave lab
208208
Jenkinsfile.defaultNodeName = 'myNode'
209209
```
210210

211-
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.
211+
Alternatively, you can assign all of your pipelines to a particular Jenkins agent label without using code, by setting a `DEFAULT_NODE_NAME` environment variable on your Jenkins server.
212212

213213
# Pipeline Stages
214214

@@ -403,4 +403,4 @@ If no `.terraform-version` file is found, and no explicit version is provided, t
403403
2. It should be possible to add behaviors through Plugins and Decorations - this makes behavior addable/removable/extenable.
404404
3. Think of plugins as interchangeable Lego pieces - you can swap one piece out for another, without fundamentally altering what it is to be a Pipeline.
405405
4. There should only be one way to Production, and that way should be crystal clear.
406-
1. The master branch (or its equivalent) is the one-and-only way to Production.
406+
1. The main branch (or its equivalent) is the one-and-only way to Production.

docs/AnsiColorPlugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Enable this plugin to color the output for terraform plan and apply.
44

55
One-time setup:
6-
* Install the [AnsiColorPlugin](https://wiki.jenkins.io/display/JENKINS/AnsiColor+Plugin) on your Jenkins master.
6+
* Install the [AnsiColorPlugin](https://wiki.jenkins.io/display/JENKINS/AnsiColor+Plugin) on your Jenkins server.
77

88
```
99
// Jenkinsfile

docs/ConditionalApplyPlugin.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
This plugin is enabled by default.
44

5-
By default, changes are applied through one and only one branch - master. The ConditionalApplyPlugin enforces this by making the "Confirm" and "Apply" steps of a TerraformEnvironmentStage visible only on the master branch. You can continue to use branches and PullRequests, however, branches and PullRequests will only run the Plan step for each environment, and skip over the Confirm/Apply steps.
5+
By default, changes are applied through one and only one branch - main. The
6+
ConditionalApplyPlugin enforces this by making the "Confirm" and "Apply" steps
7+
of a TerraformEnvironmentStage visible only on the main or master branch. You can
8+
continue to use branches and PullRequests, however, branches and PullRequests
9+
will only run the Plan step for each environment, and skip over the
10+
Confirm/Apply steps.
611

712
This behavior can be changed by using `ConditionalApplyPlugin.withApplyOnBranch()`. This method accepts one or more branches. "Confirm" and "Apply" steps of TerraformEnvironmentStage will then be visible for each of the specified branches. Any branch or PullRequest not in that list will only run the Plan step for each environment, and skip over the Confirm/Apply steps.
813

@@ -12,16 +17,16 @@ Example:
1217
@Library(['terraform-pipeline']) _
1318
1419
Jenkinsfile.init(this)
15-
ConditionalApplyPlugin.withApplyOnBranch('myMasterReplacement')
20+
ConditionalApplyPlugin.withApplyOnBranch('myMainReplacement')
1621
1722
def validate = new TerraformValidateStage()
18-
// 'qa' stage will run Plan/Confirm/Apply on the 'myMasterReplacement' branch.
23+
// 'qa' stage will run Plan/Confirm/Apply on the 'myMainReplacement' branch.
1924
// 'qa' stage will only run Plan for all other branches and PullRequests.
2025
def deployQa = new TerraformEnvironmentStage('qa')
21-
// 'uat' stage will run Plan/Confirm/Apply on 'myMasterReplacement' branch.
26+
// 'uat' stage will run Plan/Confirm/Apply on 'myMainReplacement' branch.
2227
// 'uat' stage will only run Plan for all other branches and PullRequests.
2328
def deployUat = new TerraformEnvironmentStage('uat')
24-
// 'prod' stage will run Plan/Confirm/Apply on 'myMasterReplacement' branch.
29+
// 'prod' stage will run Plan/Confirm/Apply on 'myMainReplacement' branch.
2530
// 'prod' stage will only run Plan for all other branches and PullRequests.
2631
def deployProd = new TerraformEnvironmentStage('prod')
2732
@@ -45,9 +50,9 @@ ConditionalApplyPlugin.withApplyOnEnvironment('qa')
4550
def validate = new TerraformValidateStage()
4651
// 'qa' stage will run Plan/Confirm/Apply on all branches and PullRequests.
4752
def deployQa = new TerraformEnvironmentStage('qa')
48-
// 'uat' stage will run Plan/Confirm/Apply only on master, and will only run Plan on all other branches and PullRequests.
53+
// 'uat' stage will run Plan/Confirm/Apply only on main, and will only run Plan on all other branches and PullRequests.
4954
def deployUat = new TerraformEnvironmentStage('uat')
50-
// 'prod' stage will run Plan/Confirm/Apply only on master, and will only run Plan on all other branches and PullRequests.
55+
// 'prod' stage will run Plan/Confirm/Apply only on main, and will only run Plan on all other branches and PullRequests.
5156
def deployProd = new TerraformEnvironmentStage('prod')
5257
5358
validate.then(deployQa)

docs/CredentialsPlugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Enable this plugin to inject credentials into your stages using the [Jenkins Credentials Plugin](https://wiki.jenkins.io/display/JENKINS/Credentials+Plugin).
44

55
One-time setup:
6-
* Install the [Jenkins Credentials Binding Plugin](https://www.jenkins.io/doc/pipeline/steps/credentials-binding/) on your Jenkins master.
6+
* Install the [Jenkins Credentials Binding Plugin](https://www.jenkins.io/doc/pipeline/steps/credentials-binding/) on your Jenkins server.
77
* Define a credential that you want to inject.
88

99
Add any number of credentials bindings that you want to wrap your stages, with `withBinding`. Each call to this method will cumulatively add more credentials. See the [Credentials Binding Plugin homepage](https://www.jenkins.io/doc/pipeline/steps/credentials-binding/) for the list of supported bindings.

docs/ParameterStoreBuildWrapperPlugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Enable this plugin to inject variables using the [AWS Parameter Store Build Wrapper Plugin](https://plugins.jenkins.io/aws-parameter-store)
44

55
One-time step:
6-
* Install the AWS Parameter Store Build Wrapper Plugin on your Jenkins master
6+
* Install the AWS Parameter Store Build Wrapper Plugin on your Jenkins server
77
* For cross-account deployments, create an AWS Credential with the id '<ENVIRONMENT>_PARAMETER_STORE_ACCESS' that provides access to ParameterStore for that account.
88

99
By default, parameters will be retrieved from the ParameterStore path constructed from your project's Git Organization, Git Repository name, and environment. Eg: If my terraform project were at https://github.com/Manheim/fake-terraform-project, then my 'qa' environment would receive parameters from the ParameterStore path '/Manheim/fake-terraform-project/qa'.

docs/TerraformTaintPlugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ There are several ways to customize where and when the taint/untaint can run:
2121
Jenkinsfile.init(this, env)
2222
2323
// This enables the "taint" and "untaint" functionality
24-
// It will only apply to the master branch (default behavior)
24+
// It will only apply to the main branch (default behavior)
2525
TerraformTaintPlugin.init()
2626
2727
def validate = new TerraformValidateStage()

src/ConditionalApplyPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import static TerraformEnvironmentStage.APPLY
44
public class ConditionalApplyPlugin implements TerraformEnvironmentStagePlugin, Resettable {
55

66
private static enabled = true
7-
private static DEFAULT_BRANCHES = ['master']
7+
private static DEFAULT_BRANCHES = ['main', 'master']
88
private static branches = DEFAULT_BRANCHES
99
private static environments = []
1010

src/RegressionStage.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ class RegressionStage implements Stage, DecoratableStage, Resettable {
4848
checkout scm
4949
sh testCommand
5050
} else if (automationRepoList.size() == 1) {
51-
checkout resolveScm(source: [$class: 'GitSCMSource', remote: automationRepoList.first(), traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'], [$class: 'LocalBranchTrait']]], targets: [BRANCH_NAME, 'master'])
51+
checkout resolveScm(source: [$class: 'GitSCMSource', remote: automationRepoList.first(), traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'], [$class: 'LocalBranchTrait']]], targets: [BRANCH_NAME, 'main'])
5252
sh testCommand
5353
} else {
5454
for (url in automationRepoList) {
5555
def dirName = url.split('/').last() - '.git'
5656
dir(dirName) {
57-
checkout resolveScm(source: [$class: 'GitSCMSource', remote: url, traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'], [$class: 'LocalBranchTrait']]], targets: [BRANCH_NAME, 'master'])
57+
checkout resolveScm(source: [$class: 'GitSCMSource', remote: url, traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'], [$class: 'LocalBranchTrait']]], targets: [BRANCH_NAME, 'main'])
5858
}
5959
}
6060

0 commit comments

Comments
 (0)