You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: document targeting a step's Git resource at release creation
Adds a section to the build-server-plugin release-creation page covering the
git_resources input (create-release GitHub Action v4.2.0+) and the CLI
--git-resource flag, for targeting a step's Git resource branch/tag (e.g. the
Update Argo CD Application Manifests source) from CI. Clarifies it is distinct
from the project's Git Reference/Commit and is resolved at release-creation
time (SF-2251).
title: Creating releases from a build server plugin on a version-controlled project
6
6
description: Examples of how to ensure that the right branch is used to create the release when using a build server plugin.
7
-
navOrder: 45
7
+
navOrder: 45
8
8
icon: fa-brands fa-git-alt
9
9
---
10
10
@@ -21,63 +21,88 @@ import BuildServerPluginVersionControlFields from 'src/shared-content/projects/v
21
21
Below are some examples of how to auto populate these fields using build parameters for common build servers.
22
22
23
23
## Azure DevOps
24
-
24
+
25
25
Azure DevOps stores information differently based on if the build is triggered by a branch push versus via a Pull Request (PR). You need to use a conditional statement to select the right variable. Here's a suggested method to do so.
**Note:** this approach doesn't populate the commit details for manually triggered runs. It is recommended that you provide the values for both branch and commit in this case.
38
40
39
-
40
41
## Github Actions
41
42
42
43
Github Actions provides different event data based on if the build is triggered by a branch push versus via a Pull Request (PR). You need to use a conditional statement to select the right variable. Here's a suggested method to do so.
**Note:** this approach doesn't populate the commit details for manually triggered runs. It is recommended that you provide the values for both branch and commit in this case.
55
58
56
-
57
59
## TeamCity
58
60
59
-
TeamCity provides different data based on if the build is triggered by a branch push versus via a Pull Request (PR). There is no easy way to automate selecting the right one. Based on your process, we suggest using one of the following options.
61
+
TeamCity provides different data based on if the build is triggered by a branch push versus via a Pull Request (PR). There is no easy way to automate selecting the right one. Based on your process, we suggest using one of the following options.
60
62
61
63
### Git reference
62
64
63
-
If the build is triggered by a branch push, use
64
-
```
65
+
If the build is triggered by a branch push, use
66
+
67
+
```text
65
68
%teamcity.build.branch%
66
69
```
67
-
If the build is triggered via a PR, use
68
-
```
70
+
71
+
If the build is triggered via a PR, use
72
+
73
+
```text
69
74
%teamcity.pullRequest.source.branch%
70
75
```
71
76
72
-
73
77
### Git commit
74
78
75
79
This is the same for both scenarios.
76
-
```
80
+
81
+
```text
77
82
%build.vcs.number%
78
83
```
79
84
80
85
### Notes
86
+
81
87
If multiple VCS sources are used in a build, remember to add the fully qualified parameter that includes the VCS Root ID. For example, `teamcity.build.branch.<VCS_Root_ID>` and `build.vcs.number.<VCS_Root_ID>`.
82
88
83
-
For a build resulting from a chained step, you may need to reference a parameter from the original build dependency. It will look something like this for a *Git Commit* - `dep.<Dependant_Build_ID>.build.vcs.number` or `dep.<Dependant_Build_ID>.build.vcs.number.<VCS_Root_Id>`.
89
+
For a build resulting from a chained step, you may need to reference a parameter from the original build dependency. It will look something like this for a *Git Commit* - `dep.<Dependant_Build_ID>.build.vcs.number` or `dep.<Dependant_Build_ID>.build.vcs.number.<VCS_Root_Id>`.
90
+
91
+
## Targeting a step's Git resource
92
+
93
+
The *Git Reference* and *Git Commit* fields above select the branch/commit of the **version-controlled project itself** (its OCL configuration). Separately, a deployment step can read from a Git repository — for example, the source repository of an [Update Argo CD Application Manifests](/docs/argo-cd/steps/update-application-manifests) step — via a *Git resource*. You can choose the branch or tag for a step's Git resource **at release-creation time**, which is what lets you deploy a feature branch. Because it is resolved when the release is created, it can't be set with a deployment variable (those are evaluated later, at deployment time).
94
+
95
+
This is supported by:
96
+
97
+
- The [create-release GitHub Action](https://github.com/OctopusDeploy/create-release-action) (`v4.2.0` and later) via the `git_resources` input.
98
+
- The [Octopus CLI](/docs/octopus-rest-api/cli/octopus-release-create) via the `--git-resource` flag.
99
+
100
+
The value format is `StepName:GitRef` or `StepName:GitResourceName:GitRef`. As with *Git Reference* above, resolve the ref per event so the release tracks the feature branch — use `github.head_ref` on pull requests and `github.ref_name` on pushes (not `github.ref`, which is `refs/pull/<n>/merge` on pull requests):
101
+
102
+
```yaml
103
+
- uses: OctopusDeploy/create-release-action@v4
104
+
with:
105
+
project: 'MyProject'
106
+
git_resources: |
107
+
Update Argo CD Application Manifests:refs/heads/${{ github.head_ref || github.ref_name }}
0 commit comments