From 4f015edc057702e25f4a6c9c67cbbec452180d53 Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 30 Dec 2021 02:30:08 +0100 Subject: [PATCH] Add `repo` to `when` block (#642) Co-authored-by: 6543 <6543@obermui.de> --- docs/docs/20-usage/22-conditional-execution.md | 14 ++++++++++++++ pipeline/schema/.woodpecker/test-when.yml | 7 +++++++ pipeline/schema/schema.json | 13 +++++++++++++ 3 files changed, 34 insertions(+) diff --git a/docs/docs/20-usage/22-conditional-execution.md b/docs/docs/20-usage/22-conditional-execution.md index 6e5604c5c..bc73a8b84 100644 --- a/docs/docs/20-usage/22-conditional-execution.md +++ b/docs/docs/20-usage/22-conditional-execution.md @@ -4,6 +4,20 @@ Woodpecker supports defining conditional pipeline steps in the `when` block. If This can also be utilised on a playbook level if you have multi-arch agents and require specific pipelines to be run on specific architectures. See [platform](#platform) below. +## `repo` + +Example conditional execution by repository: + +```diff + pipeline: + slack: + image: plugins/slack + settings: + channel: dev ++ when: ++ repo: test/test +``` + ## `branch` Example conditional execution by branch: diff --git a/pipeline/schema/.woodpecker/test-when.yml b/pipeline/schema/.woodpecker/test-when.yml index 9ae413820..e8a831f8c 100644 --- a/pipeline/schema/.woodpecker/test-when.yml +++ b/pipeline/schema/.woodpecker/test-when.yml @@ -88,3 +88,10 @@ pipeline: include: [ '.woodpecker/*.yml', '*.ini' ] exclude: [ '*.md', 'docs/**' ] ignore_message: "[ALL]" + + when-repo: + image: alpine + commands: + - echo "test" + when: + repo: test/test diff --git a/pipeline/schema/schema.json b/pipeline/schema/schema.json index 550c32295..b7a5cc56f 100644 --- a/pipeline/schema/schema.json +++ b/pipeline/schema/schema.json @@ -185,6 +185,19 @@ "type": "object", "additionalProperties": false, "properties": { + "repo": { + "description": "Execute a step only on a specific repository. Read more: https://woodpecker-ci.org/docs/usage/conditional-execution#repo", + "oneOf": [ + { + "type": "array", + "items": { + "type": "string" + }, + "minLength": 1 + }, + { "type": "string" } + ] + }, "branch": { "description": "TODO Read more: https://woodpecker-ci.org/docs/usage/pipeline-syntax#branch", "type": "string"