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-context-promotion-workflows.md
+77-49Lines changed: 77 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ toc: true
10
10
11
11
##Promotion contexts in promotion hooks
12
12
13
-
Promotion Workflows with hooks in Codefresh GitOps have access to a standard set of[default parameters]({{site.baseurl}}/docs/promotions/promotion-hooks/#default-arguments-in-promotion-hooks), such as the release ID, product, and commit SHA. When you define these parameters in the hook as input parameters, their values are dynamically retrieved from the ongoing promotion.
13
+
Promotion Workflows with hooks in Codefresh GitOps have access to a standard set of[default parameters]({{site.baseurl}}/docs/promotions/promotion-hooks/#default-arguments-in-promotion-hooks), such as the release ID,current release version,product, and commit SHA. When you define these parameters in the hook as input parameters, their values are dynamically retrieved from the ongoing promotion.
14
14
15
15
Because promotion hooks run within GitOps Runtimes in your own clusters, custom parameters such as Jira ticket IDs, approver names, or Slack channel names are not automatically exposed to the promotion process. To use these custom parameters in hooks, you have two options:
16
16
* Define the custom parameters and their values manually in the workflow
@@ -104,29 +104,75 @@ max-width="60%"
104
104
##Walkthough: Using promotion hooks in Promotion Flows to handle promotion failures
105
105
106
106
Promotion hooks are designed to take action or provide information related to a release and its environments when a promotion is triggered.
107
-
In this walkthrough, you'll see how tousepromotion hooks to handle promotion failures, ensuring that stakeholders are notified with the right information—without needing to monitor the release manually.
107
+
In this walkthrough, you'll see how tocreate and export apromotioncontext, and create promotionhooks and use the promotion context to handle promotion failures, ensuring that stakeholders are notified with the right information—without needing to monitor the release manually.
108
108
109
109
This walkthrough covers:
110
+
*[Creating a Promotion Workflow template with a generic promotion context](#create-promotion-workflow-template-with-generic-promotion-context)
110
111
*[Creating Promotion Workflows with hooks](#create-promotion-workflows-with-hooks)
111
112
*[Assigning hooks in Promotion Flow](#assign-hooks-to-promotion-flow)
112
113
*[Triggering hooks in Promotion Flow](#result-of-triggering-hooks-1-and-2-work-in-the-promotion-flow)
113
114
115
+
###Create Promotion Workflow template with generic promotion context
116
+
117
+
This Promotion Workflow template:
118
+
* Defines a generic promotion context as a key-value map in JSON format.
119
+
* Uses a single parameter,`context-params`, which is a JSON string of arbitrary keys and values, such as metadata for the promotion, Jira ticket references, base URLs.
120
+
* Exports the promotion context as`PROMOTION_CONTEXT`, ensuring that it's available to any promotion hook which references it.
####Hook 1: Create Jira ticket on promotion failure and export Jira
162
+
#### Hook 1: Create Jira ticket on promotion failure and export Jiraissue URL through promotion context
118
163
This hook performs two main actions:
119
164
* Creates a Jira issue when a promotion fails.
120
-
*Defines and exports a promotion context that stores the URL of the created Jira issue, making it available to later hooks in the same Promotion Flow.
165
+
*References the exports a promotion context that stores the URL of the created Jira issue, making it available to later hooks in the same Promotion Flow.
121
166
122
167
123
168
{: .table .table-bordered .table-hover}
124
-
| Hook 1 feature| Description|
125
-
| --------------| --------------|
126
-
|**Two-step DAG structure**| The hook uses a Directed Acyclic Graph (DAG) with two tasks: first`create-issue`, then`set-promotion-context`. The second task depends on the successful creation of the Jira issue.|
127
-
|**Jira issue creation**| The`create-issue` task uses a custom container to create a Jira ticket.|
128
-
|**Promotion context definition**| After creating the Jira issue, the`set-promotion-context` task creates a JSON object with the full Jira issue URL. This JSON is saved to`/tmp/promotion-context.txt` and exported as the`PROMOTION_CONTEXT` global output.|
129
-
|**Sharing information across hooks**| By exporting`PROMOTION_CONTEXT`, later hooks in the same Promotion Flow, have access to the Jira issue URL.|
| **Two-step DAG structure** | The hook defines a Directed Acyclic Graph (DAG) with two steps:`create-issue` followed by `set-promotion-context`, which depends on successful Jira issue creation. |
172
+
| **Jira issue creation** | The `create-issue` step runs a container that creates a Jira issue and outputs its key or ID. |
173
+
| **Referenced template** | The `set-promotion-context` step uses a reusable WorkflowTemplate named `set-promotion-context`, referencing its `generate-context` template. |
174
+
| **Promotion context setup** | The `set-promotion-context` step passes a `context-params` JSON object with a dynamic Jira field value (`JIRA_ISSUE_SOURCE_FIELD`) from `create-issue` and a static base URL (`JIRA_ISSUE_URL`). It outputs this object as `PROMOTION_CONTEXT`. |
175
+
| **Global sharing of context** | The exported `PROMOTION_CONTEXT` is globally accessible to any subsequent hook in the Promotion Flow. |
| **Dynamic inputs** | Parameters like `PRODUCT_NAME`, `COMMIT_SHA`, `ERROR_MESSAGE`, and `JIRA_ISSUE_URL` are passed dynamically, allowing the message to include real-time promotion failure details. |
272
300
| **Simple and reusable Slack template** | The hook uses a standard Slack webhook and a flexible `SLACK_TEXT` format, making it easy to modify for different products or flows without changing the container logic. |
273
301
| **Promotion context usage** | The `JIRA_ISSUE_URL` from the promotion context created in the previous hook is injected into the Slack message, linking the notification directly to the Jira ticket for tracking. |
Copy file name to clipboardExpand all lines: _docs/promotions/promotion-hooks.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,8 +28,9 @@ Unlike Pre- and Post-Action Promotion Workflows, which operate on each applicati
28
28
#####When are promotion hooks triggered?
29
29
Promotion hooks can run at different stages of a product release:
30
30
***Release**: When Promotion Flow trigger creates a product release:
31
-
***On release start**: When a release is initiated
32
-
***On release end**: When a release completes, whether**successful** or**failed**
31
+
***On start**: When the release is initiated
32
+
***On success**: When the release completes successfully
33
+
***On failure**: When the release fails
33
34
***Per environment**: When a release transitions through specific environments:
34
35
***On start**: When the promotion reaches an environment
35
36
***On success**: When the promotion completes successfully in an environment
@@ -50,7 +51,7 @@ See [Assigning promotion hooks in Promotion Flows](#assigning-promotion-hooks-in
50
51
Explore examples in[Codefresh Hub for Argo](https://codefresh.io/argohub/){:target="\_blank"}.
51
52
52
53
#####Arguments in promotion hooks
53
-
A default set of arguments are available to all Promotion Workflows withhooksd. See[Default arguments in Promotion Workflows with hooks](#default-arguments-for-promotion-hooks).
54
+
A default set of arguments are available to all Promotion Workflows withhooks. See[Default arguments in Promotion Workflows with hooks](#default-arguments-for-promotion-hooks).
54
55
55
56
##Promotion hooks vs. Pre- and Post-Action Promotion Workflows
56
57
@@ -79,8 +80,9 @@ The table below describes the default arguments that are replaced with values th
79
80
{: .table .table-bordered .table-hover}
80
81
| Parameter| Description| Notes|
81
82
| --------------| --------------| --------------|
82
-
|`RELEASE_URL`| The URL link to the release associated with the promotion.| All hooks|
83
-
|`PRODUCT_NAME`| The name of the product for which the promotion release is running.| All hooks|
83
+
|`RELEASE_URL`| The URL link to the release associated with the promotion.| All hooks|
84
+
|`PRODUCT_NAME`| The name of the product for which the promotion release is running.| All hooks|
85
+
|`VERSION`| The version of the current release.| All hooks|
84
86
|`COMMIT_SHA`| The unique identifier (SHA) of the commit, generated by Git, that triggered the promotion and created the release.| All hooks|
85
87
|`PROMOTION_FLOW_NAME`| The name of the Promotion Flow triggered for the release.| All hooks|
86
88
|`RELEASE_ID`| The unique identifier of the release.| All hooks|