|
| 1 | +--- |
| 2 | +title:"How To: Skip Step If Pipeline Is Triggered With Cron" |
| 3 | +description: |
| 4 | +group:kb |
| 5 | +sub-group:articles |
| 6 | +toc:true |
| 7 | +kb:false |
| 8 | +ht:true |
| 9 | +common:false |
| 10 | +categories:[Pipelines] |
| 11 | +support-reviewed:2023-12-12 MB |
| 12 | +--- |
| 13 | + |
| 14 | +##Overview |
| 15 | + |
| 16 | +You have a build that is triggered by multiple triggers, and you need to skip a certain step if the pipeline was launched using a cron trigger. |
| 17 | + |
| 18 | +##Details |
| 19 | + |
| 20 | +###Configure Cron Trigger Message |
| 21 | + |
| 22 | +In your cron trigger configuration, set a message (e.g., "using cron") in the Message field. |
| 23 | + |
| 24 | +###Implement Conditional Step |
| 25 | + |
| 26 | +Utilize the EVENT_MESSAGE variable in your pipeline steps with a condition like: |
| 27 | + |
| 28 | +{% raw %} |
| 29 | + |
| 30 | +```yaml |
| 31 | +Freestyle: |
| 32 | + title: Running alpine image |
| 33 | + type: freestyle |
| 34 | + arguments: |
| 35 | + image: 'quay.io/codefreshplugins/alpine:3.8' |
| 36 | + commands: |
| 37 | + - echo "Displayed only when triggered by cron" |
| 38 | + when: |
| 39 | + condition: |
| 40 | + all: |
| 41 | + validateTriggerType: '"${{EVENT_MESSAGE}}" != "using cron"' |
| 42 | +``` |
| 43 | + |
| 44 | +{% endraw %} |
| 45 | + |
| 46 | +This ensures specific steps execute only when the cron job message is different from "using cron" and pipeline is triggered by cron. |
| 47 | + |
| 48 | +##Related Items |
| 49 | + |
| 50 | +[Triggers in pipelines]({{site.baseurl}}/docs/pipelines/triggers/) |
| 51 | + |
| 52 | +[Cron trigger event variables]({{site.baseurl}}/docs/pipelines/triggers/cron-triggers/#cron-event-payload) |
| 53 | + |
| 54 | +[Conditional execution of steps]({{site.baseurl}}/docs/pipelines/conditional-execution-of-steps/) |
| 55 | + |
| 56 | +[Freestyle step]({{site.baseurl}}/docs/pipelines/steps/freestyle/) |