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/kb/articles/run-step-build-trigger-by-webhook.md
+19-10Lines changed: 19 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title:"How To: Run a stepdepending on if thebuildis webhook triggered"
2
+
title:"How To: Run a stepconditionally forbuildtriggered by webhook"
3
3
description:
4
4
group:kb
5
5
sub-group:articles
@@ -11,16 +11,24 @@ categories: [Pipelines]
11
11
support-reviewed:2023-04-18 LG
12
12
---
13
13
14
-
##Overview
15
14
16
-
You wantto run a steponly ifthe build isdirectlytriggered by a webhook event, or only if it's started manually.
15
+
This article explains howto run a stepconditionally based on whetherthe build is triggered by a webhook event or manually.
17
16
18
-
For example, you may have your Slack notifications set up as steps using the[Slack notifier plugin](https://codefresh.io/steps/step/slack-notifier) within your pipeline in order to get more granular control over when and how these notifications are sent, and you want to send these notifications only if the build is automatically started via webhook, not when the build is manually
17
+
18
+
##Conditional execution of steps
19
+
20
+
You want to execute a step only when a specfic condition is met.
21
+
22
+
For example, to get more granular control over when and how Slack notifications are sent, you may have your Slack notifications set up as steps using the[Slack notifier plugin](https://codefresh.io/steps/step/slack-notifier){:target="\_blank"} within your pipeline.
23
+
24
+
You want to send these notifications only when the build is automatically triggerd via webhook, and not when it is manually
19
25
triggered.
20
26
21
-
##Details
27
+
##How to
28
+
29
+
To execute a step only when a build is manually triggered, you can create a condition to check for the value of the[system variable]({{site.baseurl}}/docs/pipelines/variables/#system-provided-variables)`CF_BUILD_TRIGGER`.
22
30
23
-
To execute a step only when a build is manually triggered, you can create a condition to check for the value of the[system-provided variable]({{site.baseurl}}/docs/pipelines/variables/#system-provided-variables)`CF_BUILD_TRIGGER`.This variable's valuewill be`webhook`if the buildwas started by a webhook event, and`build`if it was startedmanually(through UI, CLI, or API).
31
+
This variable's valueis`webhook`when the buildis triggered by a webhook event, and`build`when triggeredmanually throughtheUI, CLI, or API.
24
32
25
33
{% raw %}
26
34
@@ -40,11 +48,13 @@ steps:
40
48
41
49
{% endraw %}
42
50
43
-
Similarly, you can match for the value`build` if you wantto execute a step only if the build is manually initiated.
51
+
Conversely,to execute a step only if the build is manually initiated, you can set a condition to match the value`build`.
44
52
45
-
In child builds started with codefresh run, the value of `CF_BUILD_TRIGGER` will always be `build`. This is because although the parent build may be webhook-triggered, the child build is always started via API, which counts as a "manual" start.
53
+
##### Child builds
54
+
In child builds started with Codefresh run, the value of `CF_BUILD_TRIGGER` will always be `build`.
55
+
This is because although the parent build may be webhook-triggered, the child build is always started via API, which is considered as a "manual" start.
46
56
47
-
To get around this, you can explicitly pass this variable from the parent to the child build to override the default value.
57
+
As a workaround, you can explicitly pass this variable from the parent to the child build to override the default value.