Skip to content

Commit 65b6f57

Browse files
authored
Merge pull request #2739 from OctopusDeploy/donnybell-patch-1
2 parents c1406ec + 0b5b35c commit 65b6f57

File tree

2 files changed

+140
-0
lines changed

2 files changed

+140
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
layout: src/layouts/Default.astro
3+
pubDate: 2025-06-09
4+
modDate: 2025-06-09
5+
title: Custom step templates stored in Git
6+
icon: fa-brands fa-git-alt
7+
description: How to create step templates with a git source
8+
navOrder: 10
9+
---
10+
11+
Since Octopus 2023.4, it is now possible to create [custom step templates](/docs/projects/custom-step-templates) with scripts sourced directly from Git.
12+
13+
To start, use the same steps you would normally take to create a custom step template. Just be sure to select a compatible step as some steps aren’t suitable for being sourced from Git.
14+
15+
## Git compatible base steps
16+
17+
The built-in steps listed below are compatible with being sourced from Git and can be used for custom step templates:
18+
19+
- [Run a Script](/docs/deployments/custom-scripts/run-a-script-step)
20+
- [Run an Azure Script](/docs/deployments/azure/running-azure-powershell#running-scripts-in-octopus-cloud)
21+
- [Run an AWS CLI Script](/docs/deployments/custom-scripts/aws-cli-scripts)
22+
- [Run gcloud in a Script](/docs/deployments/google-cloud/run-gcloud-script)
23+
- [Deploy an Azure Resource Manager template](/docs/runbooks/runbook-examples/azure/resource-groups)
24+
- [Run a Service Fabric SDK PowerShell Script](/docs/deployments/custom-scripts/service-fabric-powershell-scripts)
25+
- [Run a kubectl script](https://octopus.com/blog/custom-kubectl-scripting-in-octopus)
26+
- [Deploy Kubernetes YAML](/docs/kubernetes/steps/yaml)
27+
- [Deploy a Helm Chart](/docs/kubernetes/steps/helm)
28+
- [Deploy with Kustomize](/docs/kubernetes/steps/kustomize)
29+
- [Deploy a Bicep template](https://octopus.com/blog/using-the-deploy-a-bicep-template-step)
30+
- [Deploy an AWS CloudFormation template](/docs/deployments/aws/cloudformation)
31+
32+
- [Apply a Terraform template](/docs/deployments/terraform/apply-terraform-changes)
33+
- [Destroy Terraform resources](/docs/deployments/terraform/apply-terraform-changes)
34+
- [Plan to apply a Terraform template](/docs/deployments/terraform/plan-terraform)
35+
- [Plan a Terraform destroy](/docs/deployments/terraform/plan-terraform)
36+
37+
*Note: This is not a complete list as it is anticipated that additional steps will be added*
38+
39+
You may use the filter at the top to help find a step to base your custom step template on:
40+
![Base Step Filter](https://github.com/user-attachments/assets/bdae8828-02ab-41c2-b0a1-3604640c955b)
41+
42+
## Source
43+
44+
Git compatible base steps for custom step templates will provide an option to select a source. The name of this option can differ depending on the step, including:
45+
46+
- Script Source
47+
- Template Source
48+
- Chart Source
49+
50+
To use Git as the applicable source, simply select the **Git repository** option in the Step tab.
51+
52+
![Script Source](https://github.com/user-attachments/assets/8a1d4c44-6865-4a3a-832c-206fb9a9f4b6)
53+
54+
Once **Git repository** is selected, additional options will appear below in the **Step** tab. Below are common examples while certain base steps may differ.
55+
56+
## Repository URL
57+
58+
In this section, you will specify the full URL to the root of your target repository.
59+
60+
![Repository URL](https://github.com/user-attachments/assets/5b4e9bb6-04a1-44d6-9ade-c8d306625c35)
61+
62+
## Authentication
63+
64+
Unlike database sourced custom step templates, authentication is typically required to access the repository holding the script.
65+
66+
Git credentials can be added to a Space by navigating to **Deploy ➜ Git Credentials** or via the + button in the Authentication section of the **Step** tab. Use the drop-down arrow to select the appropriate Git credentials once they have been added.
67+
68+
If newly added Git credentials aren’t showing up, click on the **circular refresh button** next to the drop-down arrow.
69+
70+
![Authentication](https://github.com/user-attachments/assets/176e86ee-5155-4b3f-bb2a-cf866ee7bf04)
71+
72+
## Branch Settings
73+
74+
In this section, you will specify the default branch name.
75+
76+
![Branch Settings](https://github.com/user-attachments/assets/46298d3c-f28c-45c3-be42-41effac326e0)
77+
78+
## Path
79+
80+
Similar to **Source**, the **Path** section will be titled differently depending on the base step type. Examples include:
81+
82+
- Script File Path
83+
- Template Path
84+
- Chart Directory
85+
86+
Any of the above allows you to specify a relative path from the root of the Git repository to the targeted item. Using the example repository of `https://Github.com/OctopusSamples/OctoPetShop.Git` and a target file residing at `Scripts/MyScript.sh` within the repository, simply use **Scripts/MyScript.sh** here as shown below:
87+
88+
![Path](https://github.com/user-attachments/assets/15666ac4-542c-432f-93ca-5057ed3e4f68)
89+
90+
## Parameters and other options
91+
92+
Different base steps used for custom step templates sourced from Git may have additional options such as **Script Parameters** and other options specific to that type of step. You may refer to the instructions found in the UI for these options or [relevant step pages](#git-compatible-base-steps) in our documentation for more information.
93+
94+
## Version management
95+
96+
For custom step templates sourced from Git, aside from the specified target item, only some of the information relating to the step template is stored in Git. Everything in the **Step**, **Parameter**, and **Settings** tab is stored in the Octopus database.
97+
98+
Once a step template is added to a project, an entry is added to the **Usage** section (located just under the title of the step template). Within **Usage**, there are two tabs:
99+
100+
- Version-Controlled Projects
101+
- Database-Backed Projects
102+
103+
Git sourced custom step templates work just like standard step templates in that they are compatible with both types of projects. However, the version displayed on the usage page is only incremented by database changes to a given custom step template.
104+
105+
Git commits that change or update the item sourced from Git are not reflected in the version numbers shown on the usage page for Git sourced custom step templates. This is handled separately when:
106+
107+
- creating a release
108+
- creating runbook snapshot (database sourced)
109+
- running a Git sourced runbook
110+
111+
## Selecting Git sourced custom step templates versions
112+
113+
Octopus offers three ways to select a Git sourced custom step template version, including:
114+
115+
- Branches
116+
- Tags
117+
- Commits
118+
119+
All three options correspond to the listed repository.
120+
121+
When creating a new release, you can see the selection that was made for the previous release. You will notice an icon corresponding to the adjacent branch name, tag, or commit hash.
122+
123+
![Select By Branch Tag Or Commit](https://github.com/user-attachments/assets/dab6f6eb-943e-4cf7-878f-e908921d6bb2)
124+
125+
In the API, this information can be found for a given Release ID under **SelectedGitResources**:
126+
127+
![SelectedGitResources](https://github.com/user-attachments/assets/7840cbb9-7fd0-4590-bb77-d81852b3ccc1)
128+
129+
## Git Protection Rules
130+
131+
Similar to packages, you also have the option to implement [Git Protection Rules](/docs/releases/channels#git-protection-rules) for custom step templates stored in Git.
132+
133+
## Additional resources
134+
135+
You can find more information on Git sourced steps with the resources below:
136+
137+
- [Using Git resources directly in deployments](https://octopus.com/blog/git-resources-in-deployments)
138+
- [Octopus 2023.4: Source Scripts in Git](https://www.youtube.com/watch?v=waUktRhFY-g)
139+
140+
File renamed without changes.

0 commit comments

Comments
 (0)