Buildpipe
A Buildkite plugin to dynamically generate pipelines. Especially useful for monorepos where you want to create dependencies between projects.
Example
initial_pipeline.yml
steps:
- label: ":buildkite:"
plugins:
- jwplayer/buildpipe#v0.8.0:
dynamic_pipeline: dynamic_pipeline.yml
dynamic_pipeline.yml
projects:
- label: project1
path: project1/ # changes in this dir will trigger steps for project1
skip: deploy* # skip steps with label matching deploy* (e.g. deploy-prd)
- label: project2
skip: test
path:
- project2/
- project1 # you can trigger a project using multiple paths
- label: project3
skip: # you can skip a list of projects
- test
- deploy-stg
path: project3/somedir/ # subpaths can also be triggered
steps: # the same schema as regular buildkite pipeline steps
- label: test
env:
BUILDPIPE_SCOPE: project # this variable ensures a test step is generated for each project
command:
- cd $$BUILDPIPE_PROJECT_PATH # BUILDPIPE_PROJECT_PATH will be set by buildpipe
- make test
- wait
- label: build
branches: "master"
env:
BUILDPIPE_SCOPE: project
command:
- cd $$BUILDPIPE_PROJECT_PATH
- make build
- make publish-image
agents:
- queue=build
- wait
- label: tag
branches: "master"
command:
- make tag-release
- wait
- label: deploy-stg
branches: "master"
env:
BUILDPIPE_SCOPE: project
command:
- cd $$BUILDPIPE_PROJECT_PATH
- make deploy-staging
- wait
- block: ":rocket: Release!"
branches: "master"
- wait
- label: deploy-prd
branches: "master"
env:
BUILDPIPE_SCOPE: project
command:
- cd $$BUILDPIPE_PROJECT_PATH
- make deploy-prod
The above pipelines specify the following:
- There are three projects to track in the repository.
- The env variable
BUILDPIPE_SCOPE: projecttells buildpipe to generate a step for each project if that project changed. - The
skipoption will skip any step label matchingdeploy*. - The env variable
BUILDPIPE_PROJECT_PATHis created by buildpipe as the project's path. If multiple paths are specified for a project, it's the first path.
Full working example
For a full working example, check out Buildkite Monorepo Example.
Configuration
Plugin
| Option | Required | Type | Default | Description |
|---|---|---|---|---|
| default_branch | No | string | master | Default branch of repository |
| diff_pr | No | string | Override command for non-default branch (see below for a better explanation of the defaults) | |
| diff_default | No | string | Override command for default branch (see below for a better explanation of the defaults) | |
| dynamic_pipeline | Yes | string | The name including the path to the pipeline that contains all the actual steps | |
| log_level | No | string | INFO | The Level of logging to be used by the python script underneath; pass DEBUG for verbose logging if errors occur |
Project schema
| Option | Required | Type | Default | Description |
|---|---|---|---|---|
| label | Yes | string | Project label | |
| path | Yes | array | The path(s) that specify changes to a project | |
| skip | No | array | Exclude steps that have labels that match the rule |
Other useful things to note:
- Option
skipmake use of Unix shell-style wildcards (Look at .gitignore files for inspiration) - If multiple paths are specified, the environment variable
BUILDPIPE_PROJECT_PATHwill be the first path.
diff_ commands
Depending on your merge strategy, you might need to use different diff command.
Buildpipe assumes you are using a merge strategy on the default branch, which is assumed to be master.
The command for the non-default branch (e.g. when you have a PR up) is:
git log --name-only --no-merges --pretty=format: origin..HEAD
The command for the default branch you merge to is currently:
git log -m -1 --name-only --pretty=format: $BUILDKITE_COMMIT
Requirements
Python3 is currently required, but we are planning to convert buildpipe to a binary using Go.
Just make sure to install Python3 in your agent bootstrap script or Dockerfile.
Cloudformation bootstrap script
# Install python3
yum -y install python3 python3-pip
pip3 install -U setuptools wheel
Agent Dockerfile
FROM buildkite/agent:3.0
RUN apk add --no-cache \
# Languages
python3 py-setuptools
Troubleshooting
Buildpipe is incorrectly showing project as changed
Buildkite doesn't by default do clean checkouts. To enable clean
checkouts set the BUILDKITE_CLEAN_CHECKOUT environment variable. An
example is to modify the pre-checkout hook,
.buildkite/hooks/pre-checkout:
#!/bin/bash
set -euo pipefail
echo '--- :house_with_garden: Setting up pre-checkout'
export BUILDKITE_CLEAN_CHECKOUT="true"
Testing
make test
License
MIT
Acknowledgements
The rewrite to a plugin was inspired by git-diff-conditional-buildkite-plugin.
Metadata
Release files for buildpipe 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| buildpipe-0.8.0.tar.gz | 110.4 kB | Without provenance | Details for buildpipe-0.8.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| buildpipe-0.8.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for buildpipe-0.8.0-py2.py3-none-any.whl |
Total release size: 117.7 kB
Release files / buildpipe-0.8.0.tar.gz
| Download URL | buildpipe-0.8.0.tar.gz |
|---|---|
| Size | 110.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0be623e3b3453a87801c734a53dfec0bf5dc3482e6b9dd989194a243dc0df732
|
|
BLAKE2b-256 checksum How to use checksums |
2c1751daec4d28f3a586121b5c0c3a9ebbcb3fb15b992bfdec614a91d5682924
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Release files / buildpipe-0.8.0-py2.py3-none-any.whl
| Download URL | buildpipe-0.8.0-py2.py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f178ccadeda728a3c8b3ef361ad579ea2cce6146babbdfe3cfe18eb5b9f9cbdc
|
|
BLAKE2b-256 checksum How to use checksums |
26fc97187a12c81ab2a69f83ff766a36a0b9d4b9f7def6599c88e8f95b8a7f11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Security for buildpipe 0.8.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.