Code Monkey home page Code Monkey logo

pipeline-schema's Introduction

Buildkite Pipeline JSON Schema Build status

A JSON Schema for Buildkite’s pipeline file format, covering all current, documented options. Useful for linting/validating your pipeline.yml files using tools like YAML VSCode Extension by Red Hat.

Screenshot of YAML VSCode Extension by Red Hat

See:

Testing

If you have Node 10+ installed:

cd test
npm install && npm test

Or you can use Docker Compose:

cd test
docker-compose build && docker-compose run --rm tests

Contributing

See contributing.md

Contributors

Many thanks to our fine contributors! A full list can be found here, but you're all amazing, and we greatly appreciate your input ❤️

pipeline-schema's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pipeline-schema's Issues

Improve plugins section

Hi buildkite,

According to the schema, plugins should be an array of objects. However, in practice, buildkite happily accepted a pipeline with the following syntax:

    plugins:
      - ssh://[email protected]/bkpl/namespace.git
      - docker-compose:
          run: k6-pipeline
          command: ["run", "tests/creditCardMakePayment.js"]
          config:
            - ./loadtesting/k6/docker-compose.yml

Note that the first item in the plugins array is of type string, not object.

Can we update the schema to reflect what we have in prod? Thanks!

input step not supported in group

buildkite yaml like this

  - group: "Optional branch deploys"
    steps:
      - input: "Release to personal staging?"
        depends_on: "build-node-modules"

Produces an error in vscode Property input is not allowed. yaml-schema: buildkite

image

Looks similar to this issue that was fixed #8 - probably need to do someting similar for groups

I can confirm the code I gave above does indeed work.

[Feature Request] Make downloadable package via npm

Hi,

Thanks for the schema json! It has been a life saver!
However, at the moment I need to manually copy the schema.json into our solution.

The use case is simple:
We have a monorepo and we need to dynamically generate the buildkite pipeline and we built a node.js tool to do so. Having the schema allow us to validate the generated pipeline via unit test.
Hence, it would be very useful to have a library with a proper version so it can be detected by npm/yarn tools and we can update the schema when buildkite does instead of manually tracking the changes.

fields -> default warning with array

When provide array string to fieldss default, vs code shows warning
E.g

  - block: "Deploy to QA"
    fields:
      - select: "Regions"
        key: "deploy-regions"
        hint: "Which regions should we deploy this to? :earth_asia:"
        multiple: true
        default: ["ap-southeast-2", "eu-west-1"]
        options:
          - label: "Sydney"
            value: "ap-southeast-2"
          - label: "Ireland"
            value: "eu-west-1"

Error
image

Duplicate step keys pass validation but fail upload

Consider the following example pipeline with duplicate step keys:

---
steps:
- key: my_duplicate_step_key
  label: ":bash: Hello World One"
  agents:
    queue: my-queue
  command: echo "hello world"
- key: my_duplicate_step_key
  label: ":bash: Hello World Two"
  agents:
    queue: my-queue
  command: echo "hello world again"

Validating this pipeline against the schema does not raise any issues.

However, when attempting to upload the pipeline to Buildkite, an error will be presented:

Failed to upload and process pipeline: Pipeline upload rejected: 
The key "my_duplicate_step_key" has already been used by another step in this build

input step is not supported

input steps (https://buildkite.com/docs/pipelines/input-step) are shown in VSCode with this message 'Property input is not allowed.'
It looks like the input step is missing from the schema. Could you add support for it, please?
The documentation makes it sounds like the schema for input and block would be the same. If that's the case, I'd happily do a PR.

Block step is not allowed under steps > group > steps

With the following pipeline,

steps:
  - group: ":terraform: Staging Terraform"
    key: "staging-terraform"
    steps:
      - block: ":rocket: Release!"
        branches: $BUILDKITE_PIPELINE_DEFAULT_BRANCH
        key: wait-release-confirmation
        depends_on: start-gate

when checking with the current schema, I got the following error:

Schema validation errors were encountered.
  pipeline.yml::$.steps[0]: {'group': ':terraform: Staging Terraform', 'key': 'staging-terraform', 'steps': [{'block': ':rocket: Release!', 'branches': '$BUILDKITE_PIPELINE_DEFAULT_BRANCH', 'key': 'wait-release-confirmation', 'depends_on': 'start-gate'}]} is not valid under any of the given schemas
  Underlying errors caused this.
  Best Match:
    $.steps[0]: Additional properties are not allowed ('steps', 'group' were unexpected)

while Buildkite has no issue to read it.

This issue prevent us to apply the schema as pre-commit hook.

Conditionals cause pipeline.yml to fail validation

Problem

Using a conditional in a pipeline.yml file causes validation to fail with the following message: Property if is not allowed.. Shown here using the example from the Buildkite documentation, Using Conditionals:

Screen Shot 2020-01-08 at 14 44 22
Screen Shot 2020-01-08 at 14 56 53

Suspected Cause

It appears as though the schema does not currently support the if property. The schema.json does not have any attribute "if" within the commandStep.

Conditional properties were introduced approximately three months ago, so it seems likely that the schema simply has not yet been updated.

Suggested Fix

It seems likely that the fix will be similar to that in #4. This case may be simpler, as the documentation indicates only strings are supported by this property.

Start making releases

Being able to reference a specific version of the repo would be helpful. So far, the only reference would be a commit hash.

Step without commands passes validation, but fails API upload

I ran into an issue when my build pipeline accidentally included a named step that lacked a command or other body. I whittled it down to this MWE:

# .buildkite/pipeline.yml
---
steps:
  - name: foo

I use buildkite-signed-pipeline, and what it shows me is the following:

~~~ Running commands
$ trap 'kill -- $$' INT TERM QUIT; buildkite-signed-pipeline upload
2023/10/31 02:19:03 Using secret from AWS SM arn:aws:secretsmanager:us-east-2:123:secret:/buildkite-agent/non-production/signed_pipeline-xyz
2023/10/31 02:19:03 $ buildkite-agent pipeline upload --dry-run
2023-10-31 02:19:03 INFO   Searching for pipeline config...
2023-10-31 02:19:03 INFO   Found config file ".buildkite/pipeline.yml"
2023-10-31 02:19:03 INFO   Updating BUILDKITE_COMMIT to "d34db33f"
2023-10-31 02:19:03 INFO   Reading pipeline config from STDIN
2023-10-31 02:19:04 ERROR  Unrecoverable error, skipping retries
2023-10-31 02:19:04 FATAL  Failed to upload and process pipeline: Pipeline upload rejected: Step is missing a type `{"name":"foo"}`
2023/10/31 02:19:04 exit status 1

I thought i'd be clever and introduce a JSON schema validation step using the jv tool, however it seems that your JSON schema doesn't prohibit the situation i describe:

$ jv -output detailed https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json ./.buildkite/pipeline.yml
{
  "valid": true
}

Is this behaviour expected? I would think the JSON schema should reject a pipeline the API will reject.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.