Skip to content

Commit 81fccfc

Browse files
committed
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).
1 parent 3ff5c71 commit 81fccfc

1 file changed

Lines changed: 42 additions & 17 deletions

File tree

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
layout: src/layouts/Default.astro
33
pubDate: 2023-01-01
4-
modDate: 2025-09-03
4+
modDate: 2026-07-20
55
title: Creating releases from a build server plugin on a version-controlled project
66
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
88
icon: fa-brands fa-git-alt
99
---
1010

@@ -21,63 +21,88 @@ import BuildServerPluginVersionControlFields from 'src/shared-content/projects/v
2121
Below are some examples of how to auto populate these fields using build parameters for common build servers.
2222

2323
## Azure DevOps
24-
24+
2525
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.
2626

2727
For *Git Reference*, use
28-
```
28+
29+
```text
2930
$[coalesce(variables['system.pullRequest.sourceBranch'], variables['build.sourceBranch'])]
3031
```
3132

3233
For *Git Commit*, use
33-
```
34+
35+
```text
3436
$[coalesce(variables['system.pullRequest.sourceCommitId'], variables['build.sourceVersion'])]
3537
```
3638

3739
**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.
3840

39-
4041
## Github Actions
4142

4243
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.
4344

4445
For *Git Reference*, use
45-
```
46+
47+
```text
4648
${{ github.head_ref || github.ref }}
4749
```
4850

4951
For *Git Commit*, use
50-
```
52+
53+
```text
5154
${{ github.event.push.after || github.event.pull_request.head.sha }}
5255
```
5356

5457
**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.
5558

56-
5759
## TeamCity
5860

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.
6062

6163
### Git reference
6264

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
6568
%teamcity.build.branch%
6669
```
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
6974
%teamcity.pullRequest.source.branch%
7075
```
7176

72-
7377
### Git commit
7478

7579
This is the same for both scenarios.
76-
```
80+
81+
```text
7782
%build.vcs.number%
7883
```
7984

8085
### Notes
86+
8187
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>`.
8288

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 }}
108+
```

0 commit comments

Comments
 (0)