From 56826fbdc1be56da802754c99c3ea7df1c665880 Mon Sep 17 00:00:00 2001 From: yaroslav-codefresh Date: Fri, 20 Oct 2023 18:35:23 +0300 Subject: [PATCH 1/2] update docs --- docs/content/pipelines/spec.md | 202 ++++++++++++------ .../cli/commands/trigger/create.cmd.js | 4 +- .../cli/commands/trigger/delete.cmd.js | 2 +- .../cli/commands/trigger/event/create.cmd.js | 4 +- .../cli/commands/trigger/event/delete.cmd.js | 4 +- .../cli/commands/trigger/event/get.cmd.js | 4 +- lib/interface/cli/commands/trigger/get.cmd.js | 4 +- .../cli/commands/trigger/type/get.cmd.js | 4 +- 8 files changed, 151 insertions(+), 77 deletions(-) diff --git a/docs/content/pipelines/spec.md b/docs/content/pipelines/spec.md index be1448bec..ca7ff0a78 100644 --- a/docs/content/pipelines/spec.md +++ b/docs/content/pipelines/spec.md @@ -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 -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' @@ -108,7 +198,6 @@ spec: dockerfile: ./Dockerfile image_name: my-custom-docker-image tag: bla - stages: [] ``` #### Pipeline with a remote spec template brought from a git repository @@ -116,24 +205,19 @@ spec: 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 @@ -147,8 +231,6 @@ 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 @@ -156,25 +238,19 @@ spec: 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 @@ -185,6 +261,4 @@ spec: specTemplate: location: url url: 'https://raw.githubusercontent.com/codefresh-io/cli/master/codefresh.yml' - steps: {} - stages: [] ``` diff --git a/lib/interface/cli/commands/trigger/create.cmd.js b/lib/interface/cli/commands/trigger/create.cmd.js index fffa7ae8b..7f66a2994 100644 --- a/lib/interface/cli/commands/trigger/create.cmd.js +++ b/lib/interface/cli/commands/trigger/create.cmd.js @@ -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) => { diff --git a/lib/interface/cli/commands/trigger/delete.cmd.js b/lib/interface/cli/commands/trigger/delete.cmd.js index 9849972ac..c88bf2432 100644 --- a/lib/interface/cli/commands/trigger/delete.cmd.js +++ b/lib/interface/cli/commands/trigger/delete.cmd.js @@ -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) => { diff --git a/lib/interface/cli/commands/trigger/event/create.cmd.js b/lib/interface/cli/commands/trigger/event/create.cmd.js index 2aad11d57..de9320cb2 100644 --- a/lib/interface/cli/commands/trigger/event/create.cmd.js +++ b/lib/interface/cli/commands/trigger/event/create.cmd.js @@ -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 diff --git a/lib/interface/cli/commands/trigger/event/delete.cmd.js b/lib/interface/cli/commands/trigger/event/delete.cmd.js index 3fa23c57f..3f124ad5d 100644 --- a/lib/interface/cli/commands/trigger/event/delete.cmd.js +++ b/lib/interface/cli/commands/trigger/event/delete.cmd.js @@ -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 diff --git a/lib/interface/cli/commands/trigger/event/get.cmd.js b/lib/interface/cli/commands/trigger/event/get.cmd.js index dcb96cd35..2fe005861 100644 --- a/lib/interface/cli/commands/trigger/event/get.cmd.js +++ b/lib/interface/cli/commands/trigger/event/get.cmd.js @@ -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 diff --git a/lib/interface/cli/commands/trigger/get.cmd.js b/lib/interface/cli/commands/trigger/get.cmd.js index dc28db5a1..26e157409 100644 --- a/lib/interface/cli/commands/trigger/get.cmd.js +++ b/lib/interface/cli/commands/trigger/get.cmd.js @@ -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 -o json`)', webDocs: { category: 'Triggers', - title: 'Get Triggers', + title: '[Deprecated] Get Triggers', }, builder: (yargs) => { yargs diff --git a/lib/interface/cli/commands/trigger/type/get.cmd.js b/lib/interface/cli/commands/trigger/type/get.cmd.js index 2bd7ce135..58d6d3914 100644 --- a/lib/interface/cli/commands/trigger/type/get.cmd.js +++ b/lib/interface/cli/commands/trigger/type/get.cmd.js @@ -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 From 6ee15e6b29771a4dd25bcab182f67fe2235b5e85 Mon Sep 17 00:00:00 2001 From: yaroslav-codefresh Date: Fri, 20 Oct 2023 18:35:43 +0300 Subject: [PATCH 2/2] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e5619d66..600e359da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.87.0", + "version": "0.87.1", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,