Skip to content

Commit ea0a8f4

Browse files
authored
Q3 s3 cron triggers (#790)
* Update cron trigger with new git simulation feature Updated help article with first draft of new content and screenshots * Update pipeline specs with cron triggers Added cron triggers args table to pipeline specifications * Update cron triggers in pipeline specs Added descriptions for all cron trigger params in pipeline specs * Update codefresh-api.md * Edit content for cron triggers Content edits and updated nav entry to align with article title * Replace cron settings screenshot Added cron settings screenshot * Update cron-triggers.md * Update with feedback * Add migrate desc for legacy triggers * Update cron-triggers.md * Update cron-triggers.md Added note indicating beta version and xref to cron specs in Related Articles * Update cron-triggers.md Fixed xrefs to git triggers * Update cron-triggers.md
1 parent 068fbdf commit ea0a8f4

File tree

9 files changed

+186
-44
lines changed

9 files changed

+186
-44
lines changed

_data/nav.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@
414414
url: "/helm-triggers"
415415
- title: Artifactory triggers
416416
url: "/jfrog-triggers"
417-
- title: Timer (Cron) triggers
417+
- title: Cron (timer) triggers
418418
url: "/cron-triggers"
419419
- title: Variables in pipelines
420420
url: "/variables"

_docs/integrations/codefresh-api.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ externalResources:
430430

431431
### Git triggers
432432

433-
The `triggers` field is an array of objects that hold [Git trigger information]({{site.baseurl}}/docs/pipelines/triggers/git-triggers/) with the following fields.
433+
The `triggers` field is an array of objects that hold [Git trigger information]({{site.baseurl}}/docs/pipelines/triggers/git-triggers/).
434434

435435
{: .table .table-bordered .table-hover}
436436
| Field name | Parent field | Type | Value |
@@ -517,6 +517,49 @@ triggers:
517517
{% endraw %}
518518
{% endhighlight %}
519519

520+
### Cron triggers
521+
522+
The `cronTriggers` field is an array of objects that hold [Cron trigger information]({{site.baseurl}}/docs/pipelines/triggers/cron-triggers/).
523+
524+
{: .table .table-bordered .table-hover}
525+
| Field name | Parent field | Type | Value |
526+
| -------------- | ---------------------------- |-------------------------| -------------------------|
527+
| `event` | `cronTriggers` | string | Leave empty. Automatically generated by Codefresh for internal use. |
528+
| `name` | `cronTriggers` | string | The user-defined name for the Cron trigger. |
529+
| `message` | `cronTriggers` | string |The free-text message to be sent as an additional event payload every time the Cron trigger is activated. For example, `Successful ingress tests` |
530+
| `expression` | `cronTriggers` | string |The Cron expression that defines the time and frequency of the Cron trigger.<br>For example, `0 3 * * 1-5` triggers the pipeline at _3:00 AM every weekday (Monday to Friday)_. |
531+
| `disabled ` | `cronTriggers` | boolean | Determines if the Cron trigger is enabled for activation. <br>By default, set to `false` meaning that it is always enabled. <br>To disable the trigger, set to `true`. |
532+
| `gitTriggerId` | `cronTriggers` | string | The ID of the Git trigger to simulate for the pipeline, retrieved from the pipeline for which it is defined.<br>To simulate a Git trigger, the pipeline must have at least one Git trigger defined for it.<br>See [Git triggers](#git-triggers) in this article. |
533+
| `branch` | `cronTriggers` | string | Valid only when a Git trigger is simulated.<br> The branch of the repo retrieved from the Git trigger defined in `gitTriggerId`. |
534+
| `variables` | `cronTriggers` | array | The environment variables to populate for the pipeline when the Cron trigger is activated. See [Variables in pipelines]({{site.baseurl}}/docs/pipelines/variables/). |
535+
| `options` | `cronTriggers` | array | The behavior override options to implement for the current build. By default all overrides are set to `false`, meaning that the build inherits the default behavior set for the pipeline at the account level. <br>Can be any of the following:<br>{::nomarkdown}<ul><li><code class="highlighter-rouge">noCfCache</code>: When set to <code class="highlighter-rouge">true</code>, ignores Docker engine cache for build. See <a href="https://codefresh.io/docs/docs/kb/articles/disabling-codefresh-caching-mechanisms">Docker engine cache</a></li><li><code class="highlighter-rouge">noCache</code>: When set to <code class="highlighter-rouge">true</code>, ignores the last build's cache. Selecting this option may slow down your build.<br>See <a href="https://codefresh.io/docs/docs/kb/articles/disabling-codefresh-caching-mechanisms">Last build cache</a>.</li><li><code class="highlighter-rouge">resetVolume</code>: When set to <code class="highlighter-rouge">true</code>, resets the pipeline volume, useful for troubleshooting a build that hangs on the first step.<br> See <a href="https://codefresh.io/docs/docs/kb/articles/restoring-data-from-pre-existing-image-hangs-on/" target="_blank">Hangs on restoring data from pre-existing image</a>.</li><li><code class="highlighter-rouge">enableNotifications</code>: When set to <code class="highlighter-rouge">true</code>, sends email and Slack notifications, in addition to status updates to your Git provider.<br>See <a href="https://codefresh.io/docs/docs/integrations/notifications/slack-integration/" target="_blank">Slack notifications</a>.</li></ul>{:/}|
536+
537+
538+
`Pipeline Spec example for Cron triggers`
539+
{% highlight yaml %}
540+
{% raw %}
541+
...
542+
cronTriggers:
543+
- name: SSO sync
544+
type: cron,
545+
message: "Sync successfull"
546+
expression: "0 0/1 * 1/1 * *"
547+
gitTriggerId: 64905de8589da959de81d31d
548+
branch: main
549+
variables: []
550+
options:
551+
noCfCache: false
552+
noCache: false
553+
resetVolume: false
554+
enableNotifications: true
555+
disabled: true
556+
event: cron:codefresh:0 0/1 * 1/1 * *:tests:ecef63b9ed20
557+
verified: true
558+
status: verified
559+
id: 64ddd8b04fdbcc74cc74fe80
560+
...
561+
{% endraw %}
562+
{% endhighlight %}
520563

521564
## Using Codefresh from within Codefresh
522565

Lines changed: 141 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: "Cron (Timer) triggers"
3-
description: "Run pipelines with a time schedule"
2+
title: "Cron (timer) triggers"
3+
description: "Run pipelines on a time schedule"
44
group: pipelines
55
sub_group: triggers
66
redirect_from:
@@ -10,96 +10,195 @@ redirect_from:
1010
toc: true
1111
---
1212

13-
Cron triggers allow you to create pipelines that start on a specific time schedule. This is very useful for cleanup jobs or periodic checks or any other workflow that needs to run after a time interval.
1413

15-
>All times mentioned in Cron triggers use the UTC time zone.
1614

17-
## Manage Cron Triggers with Codefresh UI
15+
Cron triggers offer a way to run Codefresh pipelines based on a specific time schedule. Cron triggers are particularly useful for tasks like regular maintenance, periodic checks, or any repetitive workflows.
1816

19-
It is possible to define and manage Cron-based pipeline triggers with Codefresh UI.
17+
Integrate additional settings in the Cron trigger such as simulating a Git event to enrich pipelines with repository details, adding/customizing environment variables, and caching, volume reuse, and notification configurations for the build.
2018

21-
### Create a new Cron Trigger
19+
By integrating these additional options, Cron triggers can initiate pipeline executions at the predefined time intervals and at the same time populate the pipeline with repo and branch information from the Git trigger, required environment variables, and specialized behavior, for the build.
2220

23-
To add a new Cron trigger, navigate to Codefresh Pipeline *Configuration* view and expand *Triggers* section. Press the `Add Trigger` button and select a `Cron` trigger type to add.
21+
Create and manage Cron triggers for pipelines through [Codefresh UI](#cron-triggers-in-codefresh-ui), as described in this article.
22+
For the specifications, see [Cron trigger specifications in pipelines]({{site.baseurl}}/docs/integrations/codefresh-api/#cron-triggers).
23+
24+
>**NOTE**:
25+
Cron triggers are created in the UTC timezone.
26+
27+
28+
## Legacy Cron triggers in Codefresh
29+
If you see Cron triggers for your pipeline tagged with {::nomarkdown}<img src="../../../../images/icons/icon-warning.png" display=inline-block">{:/} tag, it indicates that you are using the legacy version.
2430

2531
{% include image.html
2632
lightbox="true"
27-
file="/images/pipeline/triggers/add-trigger-dialog.png"
28-
url="/images/pipeline/triggers/add-trigger-dialog.png"
29-
alt="Adding new Trigger dialog"
33+
file="/images/pipeline/triggers/cron/legacy-cron-trigger-tag.png"
34+
url="/images/pipeline/triggers/cron/legacy-cron-trigger-tag.png"
35+
caption="Legacy Cron trigger in Codefresh UI"
36+
alt="Legacy Cron trigger in Codefresh UI"
37+
max-width="60%"
38+
%}
39+
40+
**Migrate legacy trigger**
41+
* Click the **Edit** icon to view the trigger.
42+
* To migrate, click **Convert**.
43+
44+
{% include image.html
45+
lightbox="true"
46+
file="/images/pipeline/triggers/cron/legacy-cron-convert.png"
47+
url="/images/pipeline/triggers/cron/legacy-cron-convert.png"
48+
caption="Migrate legacy Cron trigger in Codefresh UI"
49+
alt="Migrate legacy Cron trigger in Codefresh UI"
50+
max-width="60%"
51+
%}
52+
Codefresh migrates the legacy Cron trigger and displays a Trigger updated successfully message.
53+
* Open the trigger displays the Settings tab with additional options.
54+
55+
{% include image.html
56+
lightbox="true"
57+
file="/images/pipeline/triggers/cron/legacy-cron-after-convert.png"
58+
url="/images/pipeline/triggers/cron/legacy-cron-after-convert.png"
59+
caption="Cron trigger after migration with Settings tab"
60+
alt="Cron trigger after migration with Settings tab"
3061
max-width="60%"
3162
%}
3263

3364

34-
Visit [this page](https://github.com/codefresh-io/cronus/blob/master/docs/expression.md){:target="\_blank"} to learn about supported `cron` expression format and aliases.
65+
## Cron triggers in Codefresh UI
66+
67+
Create and manage Cron triggers for pipelines in the Codefresh UI.
68+
69+
There are two parts to creating a Cron trigger in the UI:
70+
1. Defining the schedule for the trigger
71+
To learn about supported `cron` expression formats and aliases, visit [this page](https://github.com/codefresh-io/cronus/blob/master/docs/expression.md){:target="\_blank"}.
72+
1. (Optional) Selecting additional options:
73+
* Git trigger event to simulate when the Cron trigger timer is activated. The pipeline is populated with the information from the Git repo such as the repo URL, branch name, latest commit information, including the date and author of the commit.
74+
* Variables to populate for the build
75+
* Caching, volume resuse and notification behavior to override for the build
76+
77+
>**NOTE**: Settings for Cron triggers is currently in Beta.
78+
79+
80+
## How to: Create a Cron trigger in UI
81+
**Before you begin**
3582

83+
Review:
84+
* [Git trigger settings]({{site.baseurl}}/docs/pipelines/triggers/git-triggers/#git-trigger-settings)
85+
* [Working with Git triggers]({{site.baseurl}}/docs/pipelines/triggers/git-triggers/#working-with-git-triggers)
3686

37-
Fill the following information:
87+
**How to**
3888

39-
* Use Cron helper wizard to build a valid `cron` expression or write custom `cron` expression on the last tab.
40-
* Add a free text message, that will be sent as an additional event payload every time `cron` is executed.
89+
1. In the Codefresh UI, from the sidebar, select **Pipelines**.
90+
1. Select the pipeline to which to add the trigger, and then click the **Workflow** tab.
91+
1. On the right, click **Triggers**, and then click **Add Trigger**.
92+
1. Click **Cron**, click **Next**.
4193

4294
{% include image.html
4395
lightbox="true"
44-
file="/images/pipeline/triggers/cron_trigger.png"
45-
url="/images/pipeline/triggers/cron_trigger.png"
46-
alt="Add Cron Trigger"
47-
max-width="70%"
96+
file="/images/pipeline/triggers/add-trigger-dialog.png"
97+
url="/images/pipeline/triggers/add-trigger-dialog.png"
98+
caption="Select trigger type to add"
99+
alt="Select trigger type to add"
100+
max-width="60%"
48101
%}
49102

103+
{:start="5"}
104+
1. In the **Cron Interval** tab, configure the schedule for the Cron trigger:
105+
1. Select the time interval and the frequency at which to run the pipeline.
106+
1. Use the info in the Expression Breakdown table to create a valid Cron **Expression**, or write a custom expression.
107+
1. Add a free-text message to be sent as an additional event payload every time the Cron is executed.
50108

51-
### Trigger Codefresh pipeline with cron timer
109+
{% include image.html
110+
lightbox="true"
111+
file="/images/pipeline/triggers/cron/cron-timer-tab.png"
112+
url="/images/pipeline/triggers/cron/cron-timer-tab.png"
113+
caption="Cron trigger: Cron Interval settings"
114+
alt="Cron trigger: Cron Interval settings"
115+
max-width="60%"
116+
%}
52117

53-
Now, `cron` will trigger a recurrent pipeline execution based on the defined `cron expression`.
118+
{:start="6"}
119+
1. Click **Settings**.
120+
1. Define the Git trigger simulation options:
121+
1. From the **Simulate Trigger From** drop-down list, select the type of Git trigger to simulate.
122+
The list displays all the Git triggers defined for the pipeline.
123+
1. From the **Select Branch** drop-down list, select the branch of the repository for this build.
124+
1. Expand **Variables**, and add or modify [environment variables]({{site.baseurl}}/docs/pipelines/variables/) for this build.
125+
1. Expand **Advanced Options** and select the overrides for this build. See [Advanced options]({{site.baseurl}}/docs/pipelines/triggers/git-triggers/#advanced-settings-for-git-triggers).
126+
127+
{% include image.html
128+
lightbox="true"
129+
file="/images/pipeline/triggers/cron/cron-settings-tab.png"
130+
url="/images/pipeline/triggers/cron/cron-settings-tab.png"
131+
caption="Cron trigger: Additional settings for Git event, variables, and build behavior"
132+
alt="Cron trigger: Cron trigger: Additional settings for Git event, variables, and build behavior"
133+
max-width="60%"
134+
%}
135+
136+
{:start="7"}
137+
1. To confirm click **Done**.
138+
* If you defined only the Timer settings, the build is triggered according to the Cron expression.
139+
* If you defined both the Timer and additional Settings, the build is triggered according to the Cron expression, and depending on the settings, the pipeline is populated with the information from the Git repo, additional variables, and notifications when configured.
140+
141+
142+
>**TIP**:
143+
To edit a Cron trigger after creating it, click the Edit icon.
54144

55-
## Manage Cron Triggers with Codefresh CLI
56145

57-
It is also possible to use the Codefresh Command Line client (`CLI`) to manage Cron based pipeline triggers.
146+
## Cron triggers with Codefresh CLI
58147

59-
### Cron trigger
148+
>**NOTE**:
149+
This section is relevant only for legacy Cron triggers and will be deprecated.
60150

61-
It is possible to trigger a Codefresh CD pipeline(s) periodically, using `cron` expression.
151+
You can also create and manage Cron triggers for pipelines via the [Codefresh CLI](https://cli.codefresh.io/){:target="\_blank"}.
62152

63-
You can use [Codefresh CLI](https://cli.codefresh.io/){:target="\_blank"} to set up a Codefresh `cron` trigger.
64153

65-
#### Create Cron trigger-event
66154

67-
First, you need to create a new `cron` `trigger-event` to define a recurrent event.
155+
### Create Cron trigger event via CLI
68156

69-
```sh
70-
# create DockerHub recurrent event 'once in 20 minutes'
157+
Create a new `cron` trigger by defining a Cron expression and message.
158+
To learn about supported `cron` expression formats and aliases, visit [this page](https://github.com/codefresh-io/cronus/blob/master/docs/expression.md){:target="\_blank"}.
159+
The text message is passed to linked pipelines, whenever the specified `cron` timer is triggered.
160+
161+
162+
163+
{% highlight yaml %}
164+
{% raw %}
165+
# create recurring event 'once in 20 minutes'
71166
codefresh create trigger-event --type cron --kind codefresh --value expression="0 */20 * * * *" --value message="hello-once-in-20-min"
72167

73168
# on success trigger-event UID will be printed out
74169
Trigger event: "cron:codefresh:codefresh:0 */20 * * * *:hello-once-in-20-min:107e9db97062" was successfully created.
75-
```
170+
{% endraw %}
171+
{% endhighlight %}
76172

77-
When creating a `cron trigger-event`, it is possible to specify a short text message, that will be passed to linked pipelines, every time the specified `cron` timer is triggered.
78173

79-
Visit [this page](https://github.com/codefresh-io/cronus/blob/master/docs/expression.md){:target="\_blank"} to learn about the supported `cron` expression format and aliases.
80174

81-
#### Set up pipeline trigger
175+
### Set up pipeline trigger
82176

83177
Now, lets create a new pipeline trigger, linking previously defined `cron` `trigger-event` to one or more Codefresh pipelines.
84178

85-
```
179+
180+
{% highlight yaml %}
181+
{% raw %}
86182
# create trigger, linking trigger-event UID to the pipeline UID
87-
codefresh create trigger "cron:codefresh:codefresh:0 */20 * * * *:hello-once-in-20-min:107e9db97062" 7a5622e4b1ad5ba0018a3c9c
183+
codefresh create trigger "cron:codefresh:codefresh:0 */20 * * * *:hello-once-in-20-min:107e9db97062" 7a5622e4b1ad5ba0018a3c9c
88184

89185
# create another trigger, linking the same trigger-event to another pipeline
90186
codefresh create trigger "cron:codefresh:codefresh:0 */20 * * * *:hello-once-in-20-min:107e9db97062" 4a5634e4b2cd6baf021a3c0a
91-
```
187+
{% endraw %}
188+
{% endhighlight %}
92189

93-
From now on, every 20 minutes Codefresh will trigger a pipeline execution for 2 pipelines linked to the previously specified `cron` `trigger-event` (once in 20 minutes)
190+
From now on, Codefresh will trigger a pipeline execution for two pipelines linked to the previously specified `cron` `trigger-event`, every 20 minutes (`once in 20 minutes`).
94191

95-
#### Cron Event payload
192+
## Cron event payload
96193

97-
The following variables will be available for any Codefresh pipeline linked to a `cron` `trigger-event`:
194+
The following variables are available to any Codefresh pipeline linked to a Cron trigger event:
98195

99-
- `EVENT_MESSAGE` - free text message (specified during creation)
100-
- `EVENT_TIMESTAMP` - event timestamp in RFC 3339 format
196+
- `EVENT_MESSAGE`: Free-text message (specified during creation)
197+
- `EVENT_TIMESTAMP`: Event timestamp in RFC 3339 format
101198

102199
## Related articles
103200
[Triggers in pipelines]({{site.baseurl}}/docs/pipelines/triggers)
201+
[Cron trigger specifications]({{site.baseurl}}/docs/integrations/codefresh-api/#cron-triggers)
202+
[Variables in pipelines]({{site.baseurl}}/docs/pipelines/variables)
104203
[Creating pipelines]({{site.baseurl}}/docs/pipelines/pipelines/)
105204

images/icons/icon-warning.png

363 Bytes
Loading
66.9 KB
Loading
39.7 KB
Loading
26.8 KB
Loading
49.9 KB
Loading
17.5 KB
Loading

0 commit comments

Comments
 (0)