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
Copy file name to clipboardExpand all lines: _docs/promotions/promotion-hooks.md
+31-32Lines changed: 31 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ toc: true
8
8
9
9
##What are promotion hooks?
10
10
11
-
Promotion hooks inCodefreshGitOps are specialized workflows that run at keypoints duringa product release. A product release is created when a Promotion Flow is manually or automatically triggered.
11
+
Promotion hooks in GitOpsCloudare specialized workflows that run at keystages ofa product release. A product release is created when a Promotion Flow istriggered, eithermanually or automatically.
12
12
13
13
{% include
14
14
image.html
@@ -20,13 +20,13 @@ caption="Promotion hooks in Promotion Flow"
20
20
max-width="60%"
21
21
%}
22
22
23
-
Promotion hooksare implemented usingthe sameunderlyingmechanism as standard Promotion Workflows, but run with additional context and scope on releases and environments.
24
-
Unlike Pre- and Post-Action Promotion Workflows, whichrun in specific environments and target individual applications, promotion hooks runat the release or environment level. They are not tied to a specific deployment or application, making them reusable across multiple flows. Promotion hooks enable real-time alerts, custom logic, and actions—without requiring users to monitor the promotion directly in the UI. Teams can stay informed and respond instantly as promotions progress.
23
+
Promotion hooksusethe same mechanism as standard Promotion Workflows but run with additional context and scope on releases and environments.
24
+
Unlike Pre- and Post-Action Promotion Workflows, whichoperate on each application within environments, promotion hooks runonce per release or environment. They are not tied to a specific deployment or application, making them reusable across multiple flows. Promotion hooks enable real-time alerts, custom logic, and actions—without requiring users to monitor the promotion directly in the UI. Teams can stay informed and respond instantly as promotions progress.
25
25
26
26
27
27
28
28
#####When are promotion hooks triggered?
29
-
Promotion hooks can run at different stages of a release:
29
+
Promotion hooks can run at different stages of aproductrelease:
30
30
***Release start**: When a release is initiated
31
31
***Release end**: When a release completes, whether**successful** or**failed**
32
32
***Per environment**: When a release transitions through specific environments:
@@ -38,19 +38,19 @@ See [Assigning promotion hooks in Promotion Flows](#assigning-promotion-hooks-in
38
38
39
39
#####Use cases for promotion hooks
40
40
* Auditing and visibility
41
-
Capture details on the entirepromotion release and take action
41
+
Capture details on the entireproduct release and take action.
42
42
43
43
* Notifications and reporting
44
44
Get timely alerts and notifications on success and failures alike through familiar channels. Send alerts to Slack, email, or monitoring tools based on release events to be always in the loop instead of having to constantly monitor the promotion release.
45
45
46
46
* Integration with external tools
47
47
Automate updates to ticketing systems such as Jira, or observability platforms.
48
48
49
-
For examples, check out[Codefresh Hub for Argo](https://codefresh.io/argohub/){:target="\_blank"}.
49
+
Explore examples in[Codefresh Hub for Argo](https://codefresh.io/argohub/){:target="\_blank"}.
50
50
51
-
#####Components for promotion hooks
51
+
#####Componentsrequiredfor promotion hooks
52
52
53
-
Forpromotion hooks to work in Promotion Workflows, you need these resources:
53
+
To runpromotion hooks in Promotion Workflows, you need these resources:
54
54
***(Required) Service account, service account role and role binding**
55
55
A default service account, service account role, and role binding, are automatically added to all Workflow Templates when you install the GitOps Runtime. The provided default resources are sufficient to implement promotion hooks. To use your own resources, see[Service accounts & service account roles for promotion hooks](#service-accounts--service-account-roles-for-promotion-hooks).
56
56
@@ -63,11 +63,10 @@ The table lists key differences between Promotion Workflows containing hooks and
|**Purpose**| Provides information on the release| Provides information on promoted changes in applications within an environment|
67
-
|**Execution**| Runs at release start, end (success, failure), or per environment (start, success, failure)| Runs for each application in an environment before and after promotion|
68
-
|**Scope**| Runs on cluster at release or environment level| Runs per application in the environment|
69
-
|**Effect on promotion**| Notifies on promotion status| Blocks a promotion if conditions fail|
70
-
66
+
|**Purpose**| Provides information on the release.| Provides information on promoted changes in applications within an environment.|
67
+
|**Execution**| Runs at release start, end (success, failure), or per environment (start, success, failure).| Runs for each application in an environment before and after promotion.|
68
+
|**Scope**| Runs on cluster at release or environment (once for each environment) level.| Runs per application in the environment.|
69
+
|**Effect on promotion**| {::nomarkdown}<ul><li>If a hook fails, the product release fails as well.</li>If the release is terminated, On Fail and On Release Fail hooks are run.</li>If an On Start or On Success hook fails, the On Fail hook if defined, is run.</li></ul>{:/}| Blocks the promotion when a workflow fails.|
71
70
72
71
73
72
##Promotion hooks in Shared Configuration Repository
@@ -168,15 +167,13 @@ subjects:
168
167
```
169
168
170
169
## Promotion contexts for promotion hooks
171
-
All promotion hooks receive a standard set of [default arguments](#default-arguments-in-promotion-hook-workflows) such as the release ID, product, commit SHA from the promotion mechanism.
172
-
Toexpose customdata such as Jira ticket IDs, approver names, or Slack channels, and make this data available topromotion hooks in the same Promotion Flow, you must define and export a **promotion context**.
173
-
A promotion context is a user-defined JSON objectpassed between hooks in the same Promotion Flow. Itenables sharing valuesthat the promotion mechanism cannot access by default.
170
+
All promotion hooks receive a standard set of [default arguments](#default-arguments-in-promotion-hook-workflows) such as the release ID, product, commit SHA.
171
+
Topass customvalues such as Jira ticket IDs, approver names, or Slack channels betweenpromotion hooks in the same Promotion Flow, define and export a **promotion context**.
172
+
A promotion context is a user-defined JSON objectthatenables sharing valuesnot natively available to the promotion mechanism.
174
173
175
-
Unlike standard Promotion Workflows which have built-in access to internal context, promotion hooks run within GitOps Runtimes in your own clusters. These hooks do not automatically receive customvalues unless you define and exportthe promotion context.
174
+
Unlike standard Promotion Workflows which have built-in access to internal context, promotion hooks run within GitOps Runtimes in your own clusters. These hooks do not automatically receive customparameters unless youexplicitlydefine and exporta promotion context.
176
175
177
-
Promotion contexts allow you to:
178
-
* Expose and store user-defined variables that the promotion mechanism cannot natively access
179
-
* Make those variables available as input parameters to subsequent hooks in the same Promotion Flow
176
+
Promotion contexts allow you to share user-defined variables across hooks in the Promotion Flow, making them available as input parameters to subsequent hooks.
180
177
181
178
Examples:
182
179
* Send a Slack alert to a specific channel by passing the channel name in the promotion context
@@ -228,29 +225,28 @@ spec:
228
225
...
229
226
```
230
227
231
-
### How promotionhooks work during execution
228
+
### How promotioncontext works during execution
232
229
233
-
When you assign Promotion Workflows with promotion hooks in a Promotion Flow, the promotion mechanism runs the hooks at the relevant stages of the Promotion Flow.
234
230
235
-
#####Promotion context sharing across allpromotionhooks
236
-
If a hookincludes a promotion context and exports it, the promotion mechanism passes thosecontextparameters to all subsequent hooks, regardless of whether the hooks include promotion contexts.
231
+
#####Sharingpromotioncontext
232
+
When a hookexports a promotion context, the promotion mechanism passes those parameters to all subsequent hooks in the Promotion Flow, regardless of whether the hooks include promotion contexts.
237
233
238
234
This ensures:
239
-
*Consistent access to custom data, Jira ticket ID, build number, for example throughout the Promotion Flow
240
-
*Parameters remain available across hooks runningindifferent environments or clusters.
235
+
*Context values persist across environments and clusters
236
+
*If a hook redefines a parameter alreadyinthe context, the new value takes precedence
241
237
242
238
243
239
##### Triggering the first promotion hook
244
240
When the Promotion Flow is triggered and a product release is created, the promotion mechanism:
245
-
* Passes the defaultpromotionmetadata (release ID, commit SHA for example) to the first hook
246
-
* Initializes the promotion context, if defined and exported, withanycustom values
241
+
* Passes the default metadata (release ID, commit SHA for example) to the first hook
242
+
* Initializes the promotion context, if defined and exported, with custom values
247
243
248
244
##### Triggering subsequent promotion hooks**
249
245
As the Flow progresses, the promotion mechanism:
250
246
* Retrieves the promotion context from the previous hook
251
247
* Passes the context automatically to the next hook as input parameters:
252
-
* Newcustomparameters are added to the input parameters of the next hook.
253
-
*If the same custom parameter exists also inthecurrent hook, thevalue in the current hook always takes precedence and overrides the previous one.
248
+
* New parameters are added to the input parameters of the next hook
249
+
*For existing parameters,thevalue of theparameter in the current hook always takes precedence
254
250
255
251
256
252
@@ -553,8 +549,11 @@ spec:
553
549
## Assigning promotion hooks in Promotion Flows
554
550
555
551
Assign Promotion Workflows with promotion hooks in the Promotion Flow for the release or environments:
556
-
* Release-level hooks run before the trigger environment and after the final target environment
557
-
* Environment-level hooks run on entry to or exit from each environment
552
+
* Release-level hooks run before the trigger environment and after the final target environment.
553
+
* Environment-level hooks run on entry to or exit from each environment.
554
+
* Multiple hooks can run based the stage in the product release they are configured. Promotion failure for an environment will run both On Fail hooks if configured the environment and for the release.
555
+
556
+
558
557
559
558
>**NOTE**
560
559
You cannot assign a Promotion Hook Workflow to the Trigger Environment itself.