Skip to content

Commit fe34494

Browse files
authored
Add docs for Git protection rules (#2361)
1 parent 1ab21cb commit fe34494

File tree

4 files changed

+78
-5
lines changed

4 files changed

+78
-5
lines changed
102 KB
Loading
69.7 KB
Loading
96.2 KB
Loading

src/pages/docs/releases/channels/index.md

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: src/layouts/Default.astro
33
pubDate: 2023-01-01
4-
modDate: 2023-01-01
4+
modDate: 2024-07-24
55
title: Channels
66
description: Channels allow you to dynamically change the deployment logic and lifecycle of a project based on the version being deployed.
77
navOrder: 15
@@ -22,7 +22,7 @@ When you are implementing a deployment process that uses channels you can scope
2222
- [Variables](#variables)
2323
- [Tenants](#deploy-to-tenants)
2424

25-
You can also define versioning rules per channel to ensure that only versions which meet specific criteria are deployed to specific channels.
25+
You can also define rules per channel to ensure that only package versions and Git resources which meet specific criteria are deployed to specific channels.
2626

2727
## Managing channels
2828

@@ -40,15 +40,21 @@ As you add more channels, you'll notice that they are arranged in alphabetical o
4040
4. If you want to make this the default Channel for the project, click the **Default Channel** check-box.
4141
5. Design the [version rules](#version-rules) that will be used to enforce which versions of your packages are deployed to this channel.
4242

43-
## Design the version rules {#version-rules}
43+
## Channel rules
4444

45-
Version rules assist in selecting the correct versions of packages for the Channel. They are only used when creating a release, either manually or via [project triggers](/docs/projects/project-triggers).
45+
Channels allow to you to configure rules to ensure that package versions and Git resources that meet specific criteria can be deployed using the channel.
46+
47+
When creating a release for a channel with rules, an option can be configured on the project to allow the channel rules to be ignored. This option is disabled by default on new projects, but can be enabled in project settings.
48+
49+
### Package version rules {#version-rules}
50+
51+
Package version rules assist in selecting the correct versions of packages for the Channel. They are only used when creating a release, either manually or via [project triggers](/docs/projects/project-triggers).
4652

4753
:::div{.hint}
4854
Version Rules will work best when you follow [Semantic Versioning (SemVer 2.0.0)](http://semver.org) for your versioning strategy.
4955
:::
5056

51-
1. From the **New Channel** screen, click **ADD VERSION RULE**.
57+
1. From the **New Channel** screen, click **ADD VERSION RULE** in the Package Version Rules section.
5258
2. Select the package step(s) (and as such the packages) the version rule will be applied to.
5359
3. Enter the version range in the **Version Range** field. You can use either [Nuget](https://oc.to/NuGetVersioning) or [Maven](https://oc.to/MavenVersioning) versioning syntax to specify the range of versions to include.
5460

@@ -83,6 +89,73 @@ The **Design Version Rule** window will show a list of the packages that will de
8389

8490
6. Click **SAVE**.
8591

92+
### Git protection rules {#git-protection-rules}
93+
94+
:::div{.hint}
95+
Support for Git protection rules is currently rolling out to Octopus Cloud.
96+
:::
97+
98+
Git protection rules allow you to control the use of files from Git repositories during deployments, ensuring that important environments such as Production are protected. They are used when creating a release, either manually or via [project triggers](/docs/projects/project-triggers).
99+
100+
#### External repository rules
101+
102+
You can use external repository rules to restrict which branches and tags can be used for steps that source files from an external Git repository.
103+
104+
1. From the **New Channel** screen, click **Add Rule** in the Git Protection Rules section.
105+
2. Select the step(s) that use external Git repositories the rule will be applied to.
106+
3. Enter patterns (separated by commas) to restrict which branches and/or tags can be selected when creating releases. Wildcard characters can be used, see [Glob patterns in Git rules](#git-rules-glob-patterns) for more information.
107+
4. Click **Save**.
108+
109+
:::figure
110+
![External repository rules example](/docs/releases/channels/images/external-repository-rules.png)
111+
:::
112+
113+
#### Project repository (version controlled projects)
114+
115+
For projects that use the [Config as Code feature](/docs/projects/version-control), you can use rules to restrict which branches and tags can be used as the source of the deployment process and variables when creating a release.
116+
117+
1. From the **New Channel** screen, expand the **Project Repository** section.
118+
2. Enter patterns (separated by commas) to restrict which branches and/or tags can be selected when creating releases. Wildcard characters can be used, see [Glob patterns in Git rules](#git-rules-glob-patterns) for more information.
119+
3. Click **Save**.
120+
121+
When patterns are entered, a sample of the matching branches/tags from the Git repository used by the project will be shown to help in configuring the rules.
122+
123+
:::figure
124+
![Project repository example](/docs/releases/channels/images/project-repository.png)
125+
:::
126+
127+
#### Glob patterns in Git protection rules {#git-rules-glob-patterns}
128+
129+
Branch and tag patterns used in Git protection rules support glob patterns and can include the following wildcard characters:
130+
131+
| **Character** | **Description** | **Example** |
132+
| --- | --- | --- |
133+
| `*` | Matches multiple characters except `/` | Branch pattern of `release/*` will match branch `release/1.0.0` but not `release/1.0.0/hotfix1` |
134+
| `**` | Matches multiple characters including `/` | Branch pattern of `release/**` will match branch `release/1.0.0` and `release/1.0.0/hotfix1` |
135+
| `?` | Matches a single character | Tag pattern of `v?` will match a tag of `v1` but not `v1.0.0` |
136+
| `[0-9]` | Matches a single character in the range | Tag pattern of `v[0-9].[0-9].[0-9]` will match a tag `v1.0.0` |
137+
| `[abc]` | Matches a single character from the set | Branch pattern of `release/[abc]*` will match branch `release/a-new-branch` but not `release/my-new-branch` |
138+
139+
#### Advanced patterns
140+
141+
Some Git providers support Git references outside of branches and tags. For example when a pull request is created in a GitHub repository, a merge branch will be created with a Git reference of `refs/pulls/{id}/merge`, containing the merged code between the source and target branches of the pull request.
142+
143+
To target these references in Git protection rules, you can click the **Advanced** button for project repository and external repository rules and enter advanced patterns to match on. These patterns must be fully-qualified, any existing branches or tags that were entered will be fully-qualified for you.
144+
145+
If the patterns entered in advanced section only contain branches or tags, then you can click the **Basic** button to return to entering branches and tags without needing to fully-qualify these.
146+
147+
Some examples:
148+
149+
| **Type** | **Basic pattern** | **Fully-qualified pattern** |
150+
| --- | --- | --- |
151+
| Branch | `main` | `refs/heads/main` |
152+
| Tag | `v[0-9]` | `refs/tags/v[0-9]` |
153+
| GitHub pull request | N/A | `refs/pulls/*/merge` |
154+
155+
:::figure
156+
![Advanced patterns example](/docs/releases/channels/images/project-repository.png)
157+
:::
158+
86159
## Using channels {#using-channels}
87160

88161
Once a project has more than one Channel, there a number of places they may be used.

0 commit comments

Comments
 (0)