Skip to content

Commit 010087f

Browse files
CR-20131 -- add cron triggers docs (#849)
## What ## Why ## Notes
1 parent b489a98 commit 010087f

File tree

9 files changed

+152
-78
lines changed

9 files changed

+152
-78
lines changed

docs/content/pipelines/spec.md

+138-64
Original file line numberDiff line numberDiff line change
@@ -8,79 +8,169 @@ A Pipeline also needs a `.spec` section.
88

99
### Examples
1010

11-
#### Basic Pipeline with implicit clone step (will checkout connected repo automatically)
11+
Use create/replace/delete commands to manage your pipeline
12+
13+
```shell
14+
# create pipeline
15+
codefresh create -f pipeline.yaml
16+
17+
# get created/modified pipeline spec
18+
codefresh get pipeline <name> -o yaml > pipeline.yaml
19+
20+
# update pipeline with modified pipeline spec
21+
codefresh replace -f pipeline.yaml
22+
23+
# delete pipeline using spec file
24+
codefresh delete -f pipeline.yaml
25+
```
26+
27+
See the examples of pipeline spec below to manage your pipelines.
28+
29+
#### Basic pipeline with cron triggers in spec
30+
31+
```yaml
32+
version: '1.0'
33+
kind: pipeline
34+
metadata:
35+
name: cron
36+
spec:
37+
cronTriggers:
38+
- name: every minute
39+
type: cron
40+
message: every minute
41+
expression: 0/1 * 1/1 * *
42+
steps:
43+
test:
44+
image: alpine
45+
commands:
46+
- echo test
47+
```
48+
49+
#### Basic pipeline with cron triggers with variables
50+
51+
```yaml
52+
version: '1.0'
53+
kind: pipeline
54+
metadata:
55+
name: cron
56+
spec:
57+
cronTriggers:
58+
- name: every minute
59+
type: cron
60+
message: every minute
61+
expression: 0/1 * 1/1 * *
62+
variables:
63+
- key: TEST_VAR
64+
value: 'my-test'
65+
steps:
66+
test:
67+
image: alpine
68+
commands:
69+
- echo ${{TEST_VARIABLE}}
70+
```
71+
72+
#### Basic pipeline with cron triggers with run options
73+
74+
```yaml
75+
version: '1.0'
76+
kind: pipeline
77+
metadata:
78+
name: cron
79+
spec:
80+
cronTriggers:
81+
- name: every minute
82+
type: cron
83+
message: every minute
84+
expression: 0/1 * 1/1 * *
85+
options:
86+
resetVolume: true
87+
steps:
88+
test:
89+
image: alpine
90+
commands:
91+
- echo test >> test.txt
92+
- cat test.txt
93+
```
94+
95+
#### Pipeline started by cron trigger but simulating the git trigger
96+
97+
Note that `spec.triggers.0.id` and `spec.cronTriggers.gitTriggerId`
98+
should be the same value and a valid ObjectId.
1299

13100
```yaml
14101
version: '1.0'
15102
kind: pipeline
16103
metadata:
17-
name: codefresh-io/cli/default-pipeline
18-
labels:
19-
tags: []
20-
deprecate:
21-
applicationPort: '8080'
22-
repoPipeline: true
104+
name: cron
23105
spec:
24106
triggers:
25107
- type: git
26-
repo: codefresh-io/cli
108+
name: test
109+
repo: repo-owner/repo-name
27110
events:
28111
- push.heads
29112
pullRequestAllowForkEvents: false
30113
commentRegex: /.*/gi
31114
branchRegex: /.*/gi
32115
branchRegexInput: regex
33-
provider: github
34-
contexts: []
35-
variables:
36-
- key: PORT
37-
value: '3000'
38-
- key: SECRET
39-
value: 'secret-value'
40-
encrypted: true
116+
provider: git-context-name
117+
id: 65329431edb87250ff128acc
118+
119+
cronTriggers:
120+
- name: every minute
121+
type: cron
122+
message: every minute
123+
expression: 0/1 * 1/1 * *
124+
gitTriggerId: 65329431edb87250ff128acc
125+
branch: master
126+
41127
steps:
42-
test_step_1:
128+
test:
43129
image: alpine
44-
working_directory: '${{clone_step}}'
45130
commands:
46-
- echo ls
47-
- echo "hello world"
48-
- echo "plain value $PORT"
49-
- echo "encrypted value $PAPA"
50-
- echo "value from context $COOKIE"
51-
build:
52-
type: build
53-
working_directory: '${{clone_step}}'
54-
dockerfile: ./Dockerfile
55-
image_name: my-custom-docker-image
56-
tag: foo
57-
stages: []
131+
- echo ${{CF_BRANCH}}
132+
```
133+
134+
#### **Disable** cron trigger in pipeline
135+
136+
```yaml
137+
version: '1.0'
138+
kind: pipeline
139+
metadata:
140+
name: cron
141+
spec:
142+
cronTriggers:
143+
- name: every minute
144+
type: cron
145+
message: every minute
146+
expression: 0/1 * 1/1 * *
147+
disabled: true
148+
steps:
149+
test:
150+
image: alpine
151+
commands:
152+
- echo test
58153
```
59154

60-
#### Basic Pipeline with explicit clone step
155+
#### Basic Pipeline with clone step and git trigger
61156

62157
```yaml
63158
version: '1.0'
64159
kind: pipeline
65160
metadata:
66-
name: codefresh-io/cli/basic-pipeline
67-
labels:
68-
tags: []
69-
deprecate:
70-
applicationPort: '8080'
71-
repoPipeline: true
161+
name: basic-pipeline
72162
spec:
73163
triggers:
74164
- type: git
75-
repo: codefresh-io/cli
165+
name: test
166+
repo: repo-owner/repo-name
76167
events:
77168
- push.heads
78169
pullRequestAllowForkEvents: false
79170
commentRegex: /.*/gi
80171
branchRegex: /.*/gi
81172
branchRegexInput: regex
82-
provider: github
83-
contexts: []
173+
provider: git-context-name
84174
variables:
85175
- key: PORT
86176
value: '3000'
@@ -108,32 +198,26 @@ spec:
108198
dockerfile: ./Dockerfile
109199
image_name: my-custom-docker-image
110200
tag: bla
111-
stages: []
112201
```
113202

114203
#### Pipeline with a remote spec template brought from a git repository
115204
```yaml
116205
version: '1.0'
117206
kind: pipeline
118207
metadata:
119-
name: codefresh-io/cli/from-repo
120-
isPublic: false
121-
labels:
122-
tags: []
123-
deprecate:
124-
applicationPort: '8080'
125-
repoPipeline: true
208+
name: basic-pipeline
126209
spec:
127210
triggers:
128211
- type: git
129-
repo: codefresh-io/cli
212+
name: test
213+
repo: repo-owner/repo-name
130214
events:
131215
- push.heads
132216
pullRequestAllowForkEvents: false
133217
commentRegex: /.*/gi
134218
branchRegex: /.*/gi
135219
branchRegexInput: regex
136-
provider: github
220+
provider: git-context-name
137221
contexts: []
138222
variables:
139223
- key: PORT
@@ -147,34 +231,26 @@ spec:
147231
repo: codefresh-io/cli
148232
path: codefresh.yml
149233
revision: master # can be a branch or commit. if not specified will use CF_BRANCH variable value
150-
steps: {}
151-
stages: []
152234
```
153235

154236
#### Pipeline with a remote spec template from a public git URL
155237
```yaml
156238
version: '1.0'
157239
kind: pipeline
158240
metadata:
159-
name: codefresh-io/cli/from-external
160-
isPublic: false
161-
labels:
162-
tags: []
163-
deprecate:
164-
applicationPort: '8080'
165-
repoPipeline: true
166-
project: codefresh-io/cli
241+
name: basic-pipeline
167242
spec:
168243
triggers:
169244
- type: git
170-
repo: codefresh-io/cli
245+
name: test
246+
repo: repo-owner/repo-name
171247
events:
172248
- push.heads
173249
pullRequestAllowForkEvents: false
174250
commentRegex: /.*/gi
175251
branchRegex: /.*/gi
176252
branchRegexInput: regex
177-
provider: github
253+
provider: git-context-name
178254
contexts: []
179255
variables:
180256
- key: PORT
@@ -185,6 +261,4 @@ spec:
185261
specTemplate:
186262
location: url
187263
url: 'https://raw.githubusercontent.com/codefresh-io/cli/master/codefresh.yml'
188-
steps: {}
189-
stages: []
190264
```

lib/interface/cli/commands/trigger/create.cmd.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ const command = new Command({
99
command: 'trigger [event-uri] [pipeline]',
1010
aliases: ['t'],
1111
parent: createRoot,
12-
description: 'Create trigger: link pipeline to `trigger-event`',
12+
description: '[Deprecated] Create trigger: link pipeline to `trigger-event`. Deprecated - please use pipeline spec to manager cron trigger',
1313
webDocs: {
1414
category: 'Triggers',
15-
title: 'Create Pipeline Trigger',
15+
title: '[Deprecated] Create Pipeline Trigger',
1616
weight: 5,
1717
},
1818
builder: (yargs) => {

lib/interface/cli/commands/trigger/delete.cmd.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const command = new Command({
1111
description: 'Delete trigger: unlink pipeline from `trigger-event`',
1212
webDocs: {
1313
category: 'Triggers',
14-
title: 'Delete Pipeline Trigger',
14+
title: '[Deprecated] Delete Pipeline Trigger. Deprecated - please use pipeline spec to manager cron trigger',
1515
weight: 20,
1616
},
1717
builder: (yargs) => {

lib/interface/cli/commands/trigger/event/create.cmd.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ const command = new Command({
99
command: 'trigger-event',
1010
aliases: ['te'],
1111
parent: createRoot,
12-
description: 'Create new `trigger-event`',
12+
description: '[Deprecated] Create new `trigger-event`. Deprecated - please use pipeline spec to manager cron trigger',
1313
webDocs: {
1414
category: 'Triggers',
15-
title: 'Create Trigger Event',
15+
title: '[Deprecated] Create Trigger Event',
1616
},
1717
builder: (yargs) => {
1818
yargs

lib/interface/cli/commands/trigger/event/delete.cmd.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ const command = new Command({
88
command: 'trigger-event [event-uri]',
99
aliases: ['te'],
1010
parent: deleteRoot,
11-
description: 'Delete `trigger-event`',
11+
description: '[Deprecated] Delete `trigger-event`. Deprecated - please use pipeline spec to manager cron trigger',
1212
webDocs: {
1313
category: 'Triggers',
14-
title: 'Delete Trigger Event',
14+
title: '[Deprecated] Delete Trigger Event',
1515
},
1616
builder: (yargs) => {
1717
yargs

lib/interface/cli/commands/trigger/event/get.cmd.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ const command = new Command({
1111
command: 'trigger-events [event-uri]',
1212
aliases: ['trigger-event', 'te'],
1313
parent: getRoot,
14-
description: 'Get `trigger-event`',
14+
description: '[Deprecated] Get `trigger-event`. Deprecated - please use pipeline spec to manager cron trigger',
1515
webDocs: {
1616
category: 'Triggers',
17-
title: 'Get Trigger Event',
17+
title: '[Deprecated] Get Trigger Event',
1818
},
1919
builder: (yargs) => {
2020
yargs

lib/interface/cli/commands/trigger/get.cmd.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ const command = new Command({
1010
command: 'triggers',
1111
aliases: ['trigger', 't'],
1212
parent: getRoot,
13-
description: 'Get triggers, optionally filtered by pipeline or event.',
13+
description: '[Deprecated] Get triggers, optionally filtered by pipeline or event. Deprecated - please use pipeline spec to manager cron triggers',
1414
usage: 'Only cron/registry triggers are supported (for git triggers use `codefresh get pip <pip-name> -o json`)',
1515
webDocs: {
1616
category: 'Triggers',
17-
title: 'Get Triggers',
17+
title: '[Deprecated] Get Triggers',
1818
},
1919
builder: (yargs) => {
2020
yargs

lib/interface/cli/commands/trigger/type/get.cmd.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ const command = new Command({
1111
command: 'trigger-types',
1212
aliases: ['trigger-type', 'tt'],
1313
parent: getRoot,
14-
description: 'Get a list of available trigger-types',
14+
description: '[Deprecated] Get a list of available trigger-types. Deprecated - please use pipeline spec to manager cron trigger',
1515
webDocs: {
1616
category: 'Triggers',
17-
title: 'Get Trigger Types',
17+
title: '[Deprecated] Get Trigger Types',
1818
},
1919
builder: (yargs) => {
2020
yargs

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.87.0",
3+
"version": "0.87.1",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)