woodpecker/docs/docs/20-usage/25-multi-pipeline.md

139 lines
3.3 KiB
Markdown
Raw Normal View History

# Multi pipelines
2019-11-15 11:03:15 +00:00
:::info
This Feature is only available for GitHub, Gitea & GitLab repositories. Follow [this](https://github.com/woodpecker-ci/woodpecker/issues/131) issue to support further development.
:::
2019-11-15 11:03:15 +00:00
By default, Woodpecker looks for the pipeline definition in `.woodpecker.yml` in the project root.
The Multi-Pipeline feature allows the pipeline to be split into several files and placed in the `.woodpecker/` folder. Only `.yml` and `.yaml` files will be used and files in any subfolders like `.woodpecker/sub-folder/test.yml` will be ignored. You can set some custom path like `.my-ci/pipelines/` instead of `.woodpecker/` in the [project settings](./71-project-settings.md).
2019-11-15 11:03:15 +00:00
## Rational
- faster lint/test feedback, the pipeline doesn't have to run fully to have a lint status pushed to the forge
2019-11-15 11:03:15 +00:00
- better organization of the pipeline along various concerns: testing, linting, feature apps
2021-03-02 01:06:57 +00:00
- utilizing more agents to speed up build
2019-11-15 11:03:15 +00:00
## Example multi-pipeline definition
2022-08-31 23:52:52 +00:00
:::warning
2022-08-31 23:52:52 +00:00
Please note that files are only shared between steps of the same pipeline (see [File changes are incremental](./20-pipeline-syntax.md#file-changes-are-incremental)). That means you cannot access artifacts e.g. from the `build` pipeline below in the `deploy` pipeline.
If you still need to pass artifacts between the pipelines you need use storage [plugins](./51-plugins/10-plugins.md) (e.g. one which stores files in an Amazon S3 bucket).
:::
2019-11-15 11:03:15 +00:00
```bash
.woodpecker/
2019-11-15 11:03:15 +00:00
├── .build.yml
├── .deploy.yml
├── .lint.yml
└── .test.yml
```
.woodpecker/.build.yml
2019-11-15 11:03:15 +00:00
```yaml
pipeline:
build:
image: debian:stable-slim
commands:
- echo building
- sleep 5
```
.woodpecker/.deploy.yml
2019-11-15 11:03:15 +00:00
```yaml
pipeline:
deploy:
image: debian:stable-slim
commands:
- echo deploying
depends_on:
- lint
- build
- test
```
.woodpecker/.test.yml
2019-11-15 11:03:15 +00:00
```yaml
pipeline:
test:
image: debian:stable-slim
commands:
- echo testing
- sleep 5
depends_on:
- build
```
.woodpecker/.lint.yml
2019-11-15 11:03:15 +00:00
```yaml
pipeline:
lint:
image: debian:stable-slim
commands:
- echo linting
- sleep 5
```
## Status lines
Each pipeline will report its own status back to your forge.
2019-11-15 11:03:15 +00:00
## Flow control
The pipelines run in parallel on separate agents and share nothing.
Dependencies between pipelines can be set with the `depends_on` element. A pipeline doesn't execute until all of its dependencies finished successfully.
2019-11-15 11:03:15 +00:00
The name for a `depends_on` entry is the filename without the path, leading dots and without the file extension `.yml` or `.yaml`. If the project config for example uses `.woodpecker/` as path for CI files with a file named `.woodpecker/.lint.yml` the corresponding `depends_on` entry would be `lint`.
2019-11-15 11:03:15 +00:00
```diff
pipeline:
deploy:
image: debian:stable-slim
commands:
- echo deploying
+depends_on:
+ - lint
+ - build
+ - test
```
Pipelines that need to run even on failures should set the `runs_on` tag.
2019-11-15 11:03:15 +00:00
```diff
pipeline:
notify:
image: debian:stable-slim
commands:
- echo notifying
depends_on:
- deploy
+runs_on: [ success, failure ]
2019-11-15 11:03:15 +00:00
```
Some pipelines don't need the source code, set the `skip_clone` tag to skip cloning:
```diff
pipeline:
notify:
image: debian:stable-slim
commands:
- echo notifying
depends_on:
- deploy
runs_on: [ success, failure ]
2019-11-15 11:03:15 +00:00
+skip_clone: true
```