Skip to content

Commit

Permalink
CR-20131 -- add cron triggers docs (#849)
Browse files Browse the repository at this point in the history
## What

## Why

## Notes
  • Loading branch information
yaroslav-codefresh authored Oct 20, 2023
1 parent b489a98 commit 010087f
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 78 deletions.
202 changes: 138 additions & 64 deletions docs/content/pipelines/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,79 +8,169 @@ A Pipeline also needs a `.spec` section.

### Examples

#### Basic Pipeline with implicit clone step (will checkout connected repo automatically)
Use create/replace/delete commands to manage your pipeline

```shell
# create pipeline
codefresh create -f pipeline.yaml

# get created/modified pipeline spec
codefresh get pipeline <name> -o yaml > pipeline.yaml

# update pipeline with modified pipeline spec
codefresh replace -f pipeline.yaml

# delete pipeline using spec file
codefresh delete -f pipeline.yaml
```

See the examples of pipeline spec below to manage your pipelines.

#### Basic pipeline with cron triggers in spec

```yaml
version: '1.0'
kind: pipeline
metadata:
name: cron
spec:
cronTriggers:
- name: every minute
type: cron
message: every minute
expression: 0/1 * 1/1 * *
steps:
test:
image: alpine
commands:
- echo test
```
#### Basic pipeline with cron triggers with variables
```yaml
version: '1.0'
kind: pipeline
metadata:
name: cron
spec:
cronTriggers:
- name: every minute
type: cron
message: every minute
expression: 0/1 * 1/1 * *
variables:
- key: TEST_VAR
value: 'my-test'
steps:
test:
image: alpine
commands:
- echo ${{TEST_VARIABLE}}
```
#### Basic pipeline with cron triggers with run options
```yaml
version: '1.0'
kind: pipeline
metadata:
name: cron
spec:
cronTriggers:
- name: every minute
type: cron
message: every minute
expression: 0/1 * 1/1 * *
options:
resetVolume: true
steps:
test:
image: alpine
commands:
- echo test >> test.txt
- cat test.txt
```
#### Pipeline started by cron trigger but simulating the git trigger
Note that `spec.triggers.0.id` and `spec.cronTriggers.gitTriggerId`
should be the same value and a valid ObjectId.

```yaml
version: '1.0'
kind: pipeline
metadata:
name: codefresh-io/cli/default-pipeline
labels:
tags: []
deprecate:
applicationPort: '8080'
repoPipeline: true
name: cron
spec:
triggers:
- type: git
repo: codefresh-io/cli
name: test
repo: repo-owner/repo-name
events:
- push.heads
pullRequestAllowForkEvents: false
commentRegex: /.*/gi
branchRegex: /.*/gi
branchRegexInput: regex
provider: github
contexts: []
variables:
- key: PORT
value: '3000'
- key: SECRET
value: 'secret-value'
encrypted: true
provider: git-context-name
id: 65329431edb87250ff128acc
cronTriggers:
- name: every minute
type: cron
message: every minute
expression: 0/1 * 1/1 * *
gitTriggerId: 65329431edb87250ff128acc
branch: master
steps:
test_step_1:
test:
image: alpine
working_directory: '${{clone_step}}'
commands:
- echo ls
- echo "hello world"
- echo "plain value $PORT"
- echo "encrypted value $PAPA"
- echo "value from context $COOKIE"
build:
type: build
working_directory: '${{clone_step}}'
dockerfile: ./Dockerfile
image_name: my-custom-docker-image
tag: foo
stages: []
- echo ${{CF_BRANCH}}
```

#### **Disable** cron trigger in pipeline

```yaml
version: '1.0'
kind: pipeline
metadata:
name: cron
spec:
cronTriggers:
- name: every minute
type: cron
message: every minute
expression: 0/1 * 1/1 * *
disabled: true
steps:
test:
image: alpine
commands:
- echo test
```

#### Basic Pipeline with explicit clone step
#### Basic Pipeline with clone step and git trigger

```yaml
version: '1.0'
kind: pipeline
metadata:
name: codefresh-io/cli/basic-pipeline
labels:
tags: []
deprecate:
applicationPort: '8080'
repoPipeline: true
name: basic-pipeline
spec:
triggers:
- type: git
repo: codefresh-io/cli
name: test
repo: repo-owner/repo-name
events:
- push.heads
pullRequestAllowForkEvents: false
commentRegex: /.*/gi
branchRegex: /.*/gi
branchRegexInput: regex
provider: github
contexts: []
provider: git-context-name
variables:
- key: PORT
value: '3000'
Expand Down Expand Up @@ -108,32 +198,26 @@ spec:
dockerfile: ./Dockerfile
image_name: my-custom-docker-image
tag: bla
stages: []
```

#### Pipeline with a remote spec template brought from a git repository
```yaml
version: '1.0'
kind: pipeline
metadata:
name: codefresh-io/cli/from-repo
isPublic: false
labels:
tags: []
deprecate:
applicationPort: '8080'
repoPipeline: true
name: basic-pipeline
spec:
triggers:
- type: git
repo: codefresh-io/cli
name: test
repo: repo-owner/repo-name
events:
- push.heads
pullRequestAllowForkEvents: false
commentRegex: /.*/gi
branchRegex: /.*/gi
branchRegexInput: regex
provider: github
provider: git-context-name
contexts: []
variables:
- key: PORT
Expand All @@ -147,34 +231,26 @@ spec:
repo: codefresh-io/cli
path: codefresh.yml
revision: master # can be a branch or commit. if not specified will use CF_BRANCH variable value
steps: {}
stages: []
```

#### Pipeline with a remote spec template from a public git URL
```yaml
version: '1.0'
kind: pipeline
metadata:
name: codefresh-io/cli/from-external
isPublic: false
labels:
tags: []
deprecate:
applicationPort: '8080'
repoPipeline: true
project: codefresh-io/cli
name: basic-pipeline
spec:
triggers:
- type: git
repo: codefresh-io/cli
name: test
repo: repo-owner/repo-name
events:
- push.heads
pullRequestAllowForkEvents: false
commentRegex: /.*/gi
branchRegex: /.*/gi
branchRegexInput: regex
provider: github
provider: git-context-name
contexts: []
variables:
- key: PORT
Expand All @@ -185,6 +261,4 @@ spec:
specTemplate:
location: url
url: 'https://raw.githubusercontent.com/codefresh-io/cli/master/codefresh.yml'
steps: {}
stages: []
```
4 changes: 2 additions & 2 deletions lib/interface/cli/commands/trigger/create.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const command = new Command({
command: 'trigger [event-uri] [pipeline]',
aliases: ['t'],
parent: createRoot,
description: 'Create trigger: link pipeline to `trigger-event`',
description: '[Deprecated] Create trigger: link pipeline to `trigger-event`. Deprecated - please use pipeline spec to manager cron trigger',
webDocs: {
category: 'Triggers',
title: 'Create Pipeline Trigger',
title: '[Deprecated] Create Pipeline Trigger',
weight: 5,
},
builder: (yargs) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/interface/cli/commands/trigger/delete.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const command = new Command({
description: 'Delete trigger: unlink pipeline from `trigger-event`',
webDocs: {
category: 'Triggers',
title: 'Delete Pipeline Trigger',
title: '[Deprecated] Delete Pipeline Trigger. Deprecated - please use pipeline spec to manager cron trigger',
weight: 20,
},
builder: (yargs) => {
Expand Down
4 changes: 2 additions & 2 deletions lib/interface/cli/commands/trigger/event/create.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const command = new Command({
command: 'trigger-event',
aliases: ['te'],
parent: createRoot,
description: 'Create new `trigger-event`',
description: '[Deprecated] Create new `trigger-event`. Deprecated - please use pipeline spec to manager cron trigger',
webDocs: {
category: 'Triggers',
title: 'Create Trigger Event',
title: '[Deprecated] Create Trigger Event',
},
builder: (yargs) => {
yargs
Expand Down
4 changes: 2 additions & 2 deletions lib/interface/cli/commands/trigger/event/delete.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const command = new Command({
command: 'trigger-event [event-uri]',
aliases: ['te'],
parent: deleteRoot,
description: 'Delete `trigger-event`',
description: '[Deprecated] Delete `trigger-event`. Deprecated - please use pipeline spec to manager cron trigger',
webDocs: {
category: 'Triggers',
title: 'Delete Trigger Event',
title: '[Deprecated] Delete Trigger Event',
},
builder: (yargs) => {
yargs
Expand Down
4 changes: 2 additions & 2 deletions lib/interface/cli/commands/trigger/event/get.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const command = new Command({
command: 'trigger-events [event-uri]',
aliases: ['trigger-event', 'te'],
parent: getRoot,
description: 'Get `trigger-event`',
description: '[Deprecated] Get `trigger-event`. Deprecated - please use pipeline spec to manager cron trigger',
webDocs: {
category: 'Triggers',
title: 'Get Trigger Event',
title: '[Deprecated] Get Trigger Event',
},
builder: (yargs) => {
yargs
Expand Down
4 changes: 2 additions & 2 deletions lib/interface/cli/commands/trigger/get.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const command = new Command({
command: 'triggers',
aliases: ['trigger', 't'],
parent: getRoot,
description: 'Get triggers, optionally filtered by pipeline or event.',
description: '[Deprecated] Get triggers, optionally filtered by pipeline or event. Deprecated - please use pipeline spec to manager cron triggers',
usage: 'Only cron/registry triggers are supported (for git triggers use `codefresh get pip <pip-name> -o json`)',
webDocs: {
category: 'Triggers',
title: 'Get Triggers',
title: '[Deprecated] Get Triggers',
},
builder: (yargs) => {
yargs
Expand Down
4 changes: 2 additions & 2 deletions lib/interface/cli/commands/trigger/type/get.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const command = new Command({
command: 'trigger-types',
aliases: ['trigger-type', 'tt'],
parent: getRoot,
description: 'Get a list of available trigger-types',
description: '[Deprecated] Get a list of available trigger-types. Deprecated - please use pipeline spec to manager cron trigger',
webDocs: {
category: 'Triggers',
title: 'Get Trigger Types',
title: '[Deprecated] Get Trigger Types',
},
builder: (yargs) => {
yargs
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codefresh",
"version": "0.87.0",
"version": "0.87.1",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit 010087f

Please sign in to comment.