Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit368b7e2

Browse files
authored
Update hooks.md (#1206)
* Update hooks.mdAdded section on hook behavior for parallel steps* Update hooks.md* Update hooks.md
1 parent41e3d24 commit368b7e2

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

‎_docs/pipelines/hooks.md‎

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ redirect_from:
77
toc:true
88
---
99

10-
Hooks in pipelines allow you to run specific actions at the end and the beginning of the pipeline, as well as before/after a step.
10+
Hooks in pipelines allow you to run specific actions at the end and the beginning of the pipeline, as well as before orafter a step.
1111

1212
Hooks can be a[freestyle step]({{site.baseurl}}/docs/pipelines/steps/freestyle/), as you need to define:
1313

@@ -163,7 +163,7 @@ It is possible to define all possible hooks (`on_elected`, `on_finish`, `on_succ
163163

164164
You can also define hooks for individual steps inside a pipeline. This capability allows you to enforce more granular control on defining prepare/cleanup phases for specific steps.
165165

166-
The syntax for step hooks is the same as pipeline hooks:`on_elected`,`on_finish`,`on_success`,`on_fail`. The only difference is that you need to add the respective segment within a step instead of the at the root of the pipeline.
166+
The syntax for step hooks is the same as pipeline hooks:`on_elected`,`on_finish`,`on_success`,`on_fail`. The only difference is that you need to add the respective segment within a step instead of the at the root of the pipeline.
167167

168168
For example, this pipeline will always run a cleanup step after integration tests (even if the tests themselves fail).
169169

@@ -450,6 +450,40 @@ steps:
450450

451451
You can use multiple steps in a hook in both the pipeline and the step level.
452452

453+
###Hooks in parallel steps
454+
Hooks are_not supported in[parallel step types]({{site.baseurl}}/docs/pipelines/advanced-workflows/)_.
455+
456+
However, you can add hooks to any other step type, even if the step is nested within a parallel step, as in the example below.
457+
458+
```yaml
459+
460+
version:"1.0"
461+
steps:
462+
root_parallel_step:
463+
type:parallel
464+
steps:
465+
child_step_a:
466+
image:alpine
467+
commands:
468+
-exit 0
469+
hooks:
470+
on_finish:
471+
exec:
472+
image:alpine
473+
commands:
474+
-echo "✅ This is a hook in the 'child_step_a' step nested within 'root_parallel_step'. The hook will work because 'child_step_a' is a 'freestyle' step"
475+
child_step_b:
476+
image:alpine
477+
commands:
478+
-exit 0
479+
hooks:
480+
on_finish:
481+
exec:
482+
image:alpine
483+
commands:
484+
-echo "✅ This is a hook in the `child_step_b' step which is also nested within 'root_parallel_step'. The hook will work because 'child_step_b' is a 'freestyle' step"
485+
```
486+
453487
### Referencing the 'working_directory' in step hooks
454488
To access the [`working_directory`]({{site.baseurl}}/docs/pipelines/what-is-the-codefresh-yaml/#working-directories) of a regular step through a hook, use the prefix `parentSteps.<step-name>` For example, to access the `working_directory` of the `clone` step, use {% raw %} `${{parentSteps.clone}}` {% endraw %}.
455489

@@ -614,12 +648,14 @@ hooks:
614648
{% endraw %}
615649
{% endhighlight %}
616650

651+
652+
653+
617654
## Limitations of pipeline/step hooks
618655

619-
With thecurrent implementation of hooks,the following limitations are present:
656+
Thecurrent implementation of hooks hasthe following limitations:
620657

621658
* The [debugger]({{site.baseurl}}/docs/pipelines/debugging-pipelines/) cannot inspect commands inside hook segments.
622-
* Hooks are not supported for[parallel steps]({{site.baseurl}}/docs/pipelines/advanced-workflows/).
623659
* Storage integrations don't resolve in hooks (for example, [test reports]({{site.baseurl}}/docs/testing/test-reports/#producing-allure-test-reports-from-codefresh-pipelines)).
624660

625661
## Related articles

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp