From 1b64388bf288761f10fc3e37e3f6e38f6fb01fd7 Mon Sep 17 00:00:00 2001 From: blag Date: Thu, 11 Nov 2021 14:48:10 -0800 Subject: [PATCH 1/3] Fix Markdown emphasis syntax --- docs/scheduled-pipelines.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/scheduled-pipelines.md b/docs/scheduled-pipelines.md index 17bcfbd..0af1c23 100644 --- a/docs/scheduled-pipelines.md +++ b/docs/scheduled-pipelines.md @@ -10,7 +10,7 @@ Since the scheduled run is based on pipelines, scheduled pipelines have all the CircleCI has APIs that allows users to create, view, edit, and delete Scheduled Pipelines. -**Note**: *At this time, the UI for Scheduled Pipelines is not available. It will become available soon. +**Note**: *At this time, the UI for Scheduled Pipelines is not available. It will become available soon.* ## Getting started with scheduled pipelines in CircleCI From 117b29502aefd4007239f637b80f90cde4f35337 Mon Sep 17 00:00:00 2001 From: blag Date: Thu, 11 Nov 2021 14:48:51 -0800 Subject: [PATCH 2/3] Indent source code blocks so they render within their list bullet items --- docs/scheduled-pipelines.md | 134 ++++++++++++++++++------------------ 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/docs/scheduled-pipelines.md b/docs/scheduled-pipelines.md index 0af1c23..ad9f90f 100644 --- a/docs/scheduled-pipelines.md +++ b/docs/scheduled-pipelines.md @@ -20,25 +20,25 @@ If your project has no scheduled workflows and would like to try out scheduled p - Have your CCI token ready or create a new one following [these steps](https://circleci.com/docs/2.0/managing-api-tokens/) - Create a new schedule using the new Pipelines Schedule API, for example: -``` -curl --location --request POST 'https://circleci.com/api/v2/project//schedule' \ ---header 'circle-token: ' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "name": "my schedule name", - "description": "some description", - "attribution-actor": "system", - "parameters": { - "branch": "main" - - }, - "timetable": { - "per-hour": 3, - "hours-of-day": [1,15], - "days-of-week": ["MON", "WED"] - } -}' -``` + ``` + curl --location --request POST 'https://circleci.com/api/v2/project//schedule' \ + --header 'circle-token: ' \ + --header 'Content-Type: application/json' \ + --data-raw '{ + "name": "my schedule name", + "description": "some description", + "attribution-actor": "system", + "parameters": { + "branch": "main" + + }, + "timetable": { + "per-hour": 3, + "hours-of-day": [1,15], + "days-of-week": ["MON", "WED"] + } + }' + ``` - Check out the `schedule` section under the [open-api docs](https://circleci.com/docs/api/v2/) for additional information @@ -58,69 +58,69 @@ To migrate from scheduled workflows to scheduled pipelines, one can follow the s - Find the scheduled trigger in your project's .circleci/config.yml - For example, it might look like this one: -``` -daily-run-workflow: - triggers: - - schedule: - # Every day, 0421Z. - cron: "21 4 * * *" - filters: - branches: - only: - - main - jobs: - - test - - build -``` + ``` + daily-run-workflow: + triggers: + - schedule: + # Every day, 0421Z. + cron: "21 4 * * *" + filters: + branches: + only: + - main + jobs: + - test + - build + ``` - Interpret the frequency your trigger needs to run from the cron expression - Use the same step from `Starting from scratch` section above to create the schedule via the API - In the circleci config file, remove the `triggers` section so that it looks like a normal workflow -``` -daily-run-workflow: - jobs: - - test - - build -``` + ``` + daily-run-workflow: + jobs: + - test + - build + ``` - Add workflows filtering. As scheduled pipeline is essentially a triggered pipeline, it will run every workflow in the config. - One way to implement workflows filtering is by using the pipeline values, for example: -``` -daily-run-workflow: - when: - and: - - equal: [ scheduled_pipeline, << pipeline.trigger_source >> ] - - equal: [ "my schedule name", << pipeline.schedule.name >> ] - jobs: - - test - - build -``` + ``` + daily-run-workflow: + when: + and: + - equal: [ scheduled_pipeline, << pipeline.trigger_source >> ] + - equal: [ "my schedule name", << pipeline.schedule.name >> ] + jobs: + - test + - build + ``` - Please note that in the above example, the second `equal` under `when` is not strictly necessary. The `pipeline.schedule.name` is an available pipeline value when the pipeline is triggered by a schedule. - Add workflows filtering for workflows that should NOT run when a schedule triggers: -``` -daily-run-workflow: - when: - and: - - equal: [ scheduled_pipeline, << pipeline.trigger_source >> ] - - equal: [ "my schedule name", << pipeline.schedule.name >> ] - jobs: - - test - - build - -other-workflow: - when: - not: - equal: [ scheduled_pipeline, << pipeline.trigger_source >> ] - jobs: - - build - - deploy -``` + ``` + daily-run-workflow: + when: + and: + - equal: [ scheduled_pipeline, << pipeline.trigger_source >> ] + - equal: [ "my schedule name", << pipeline.schedule.name >> ] + jobs: + - test + - build + + other-workflow: + when: + not: + equal: [ scheduled_pipeline, << pipeline.trigger_source >> ] + jobs: + - build + - deploy + ``` ## Scheduled pipeline FAQs From 432b5a3fa0c6ce4f6dd0afa02458d896fcdfea0a Mon Sep 17 00:00:00 2001 From: blag Date: Thu, 11 Nov 2021 14:52:51 -0800 Subject: [PATCH 3/3] Make examples more complete by also converting the branch filtering critera --- docs/scheduled-pipelines.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/scheduled-pipelines.md b/docs/scheduled-pipelines.md index ad9f90f..46138f1 100644 --- a/docs/scheduled-pipelines.md +++ b/docs/scheduled-pipelines.md @@ -93,6 +93,7 @@ To migrate from scheduled workflows to scheduled pipelines, one can follow the s and: - equal: [ scheduled_pipeline, << pipeline.trigger_source >> ] - equal: [ "my schedule name", << pipeline.schedule.name >> ] + - equal: [ "main", << pipeline.git.branch >> ] jobs: - test - build @@ -109,14 +110,17 @@ To migrate from scheduled workflows to scheduled pipelines, one can follow the s and: - equal: [ scheduled_pipeline, << pipeline.trigger_source >> ] - equal: [ "my schedule name", << pipeline.schedule.name >> ] + - equal: [ "main", << pipeline.git.branch >> ] jobs: - test - build other-workflow: when: - not: - equal: [ scheduled_pipeline, << pipeline.trigger_source >> ] + and: + - not: + equal: [ scheduled_pipeline, << pipeline.trigger_source >> ] + - equal: [ "main", << pipeline.git.branch >> ] jobs: - build - deploy