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/codefresh-yaml/hooks.md
+39-5Lines changed: 39 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,6 @@ Hooks can be a [freestyle step]({{site.baseurl}}/docs/codefresh-yaml/steps/frees
14
14
15
15
For simple commands we suggest you use a small image such as`alpine`, but any Docker image can be used in hooks.
16
16
17
-
Also, Hooks can use[steps/plugins](https://steps.codefresh.io) and need to define:
18
-
19
-
1. The type field for the step/plugin.
20
-
1. The arguments needed for the step/plugin.
21
-
22
17
##Pipeline hooks
23
18
24
19
Codefresh allows you to run a specific step before each pipeline as well as after it has finished.
@@ -262,6 +257,45 @@ The order of events in the example above is the following.
262
257
1. The`on_finish` segment always executes at the end
263
258
264
259
260
+
##Running[steps/plugins](https://steps.codefresh.io) in hooks:
261
+
262
+
Hooks can use[steps/plugins](https://steps.codefresh.io). With plugin you have to specify:
263
+
264
+
- The type field for the step/plugin.
265
+
- The arguments needed for the step/plugin.
266
+
267
+
`codefresh.yml`
268
+
{% highlight yaml %}
269
+
{% raw %}
270
+
version: "1.0"
271
+
272
+
hooks: #run slack-notifier hook on build completion
273
+
on_finish:
274
+
steps:
275
+
exec:
276
+
type: slack-notifier
277
+
arguments:
278
+
SLACK_HOOK_URL: '${{SLACK_WEBHOOK_URL}}'
279
+
SLACK_TEXT: '${{SLACK_TEXT}}'
280
+
281
+
steps:
282
+
step1:
283
+
title: "Freestyle step"
284
+
type: "freestyle"
285
+
image: alpine
286
+
commands:
287
+
- echo "Codefresh"
288
+
hooks: #run slack-notifier hook on step completion
289
+
on_finish:
290
+
steps:
291
+
exec:
292
+
type: slack-notifier
293
+
arguments:
294
+
SLACK_HOOK_URL: '${{SLACK_WEBHOOK_URL}}'
295
+
SLACK_TEXT: '${{SLACK_TEXT}}'
296
+
{% endraw %}
297
+
{% endhighlight %}
298
+
265
299
##Controlling errors inside pipeline/step hooks
266
300
267
301
By default if a step fails within a pipeline, the whole pipeline will stop and be marked as failed. This is also true for`on_elected` segments as well. If they fail, then the whole pipeline will fail (regardless of the position of the segment in a pipeline or step).