Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add JSON schema validation for pipeline.yaml and jenkins-x.yml #3757

Merged

Conversation

abayer
Copy link
Contributor

@abayer abayer commented Apr 25, 2019

Submitter checklist

  • Change is code complete and matches issue description.
  • Change is covered by existing or new tests.

Description

Also added jx step syntax:

  • jx step syntax schema - generates JSON schema for either pipeline.yaml or jenkins-x.yml
  • jx step syntax validate buildpacks - which validates against jenkins-x-kubernetes and jenkins-x-classic from the local clones.
  • jx step syntax validate pipeline - validates jenkins-x.yml (or another context if specified)

Note that this depends on https://github.com/abayer/jsonschema, which
I'll try to get in a PR to the original (https://github.com/alecthomas/jsonschema).

Special notes for the reviewer(s)

/assign @dwnusbaum
/assign @rawlingsj
/assign @pmuir
/assign @ccojocar
/assign @warrenbailey
/assign @hferentschik
/hold

Which issue this PR fixes

fixes #3728

Not Found
@abayer abayer force-pushed the validate-pipeline-yaml-jenkins-x-yml branch from f32c207 to 08505ae Compare April 25, 2019 20:39
@abayer
Copy link
Contributor Author

abayer commented Apr 25, 2019

I still need to add tests for jx step buildpack validate, and I'm not sure if we actually want to use my fork (https://github.com/abayer/jsonschema) or wait til I can get a PR in to the original.

@abayer abayer force-pushed the validate-pipeline-yaml-jenkins-x-yml branch from 08505ae to 5c4bfa1 Compare April 25, 2019 20:40
@abayer
Copy link
Contributor Author

abayer commented Apr 25, 2019

Oh, I also updated jenkins-x*.yml in this repo to be valid, and verified that all of our existing build packs are valid too.

@abayer
Copy link
Contributor Author

abayer commented Apr 25, 2019

...and ignore those first couple errors - I rebased before they could even kick off and they barfed as a result. =)

@abayer abayer force-pushed the validate-pipeline-yaml-jenkins-x-yml branch 2 times, most recently from 912ae79 to 2dd2ddd Compare April 25, 2019 21:23
@rawlingsj
Copy link
Member

/lgtm

@rawlingsj
Copy link
Member

@abayer just noticed you'd put this PR on hold, I've lgtm so if you're happy for it to merge just cancel the hold.

@abayer
Copy link
Contributor Author

abayer commented Apr 26, 2019

@rawlingsj - thanks, but I still want to add more tests and get a consensus on whether we want to use my fork of https://github.com/alecthomas/jsonschema. Oh, and whether we should be doing some kind of release note due to existing jenkins-x.yml files with invalid content failing once this goes live...

@abayer
Copy link
Contributor Author

abayer commented Apr 26, 2019

/assign @jstrachan

fyi, this now has jx step syntax and subcommands for validation and schema generation. =)

@abayer
Copy link
Contributor Author

abayer commented Apr 26, 2019

aaaaand opened alecthomas/jsonschema#32 to get the changes we need upstream.

@abayer
Copy link
Contributor Author

abayer commented Apr 26, 2019

/test integration

@abayer
Copy link
Contributor Author

abayer commented Apr 26, 2019

Gonna take this off hold once either my PR upstream gets merged or we know it won't. =)

@abayer abayer force-pushed the validate-pipeline-yaml-jenkins-x-yml branch from d65de26 to b6baf77 Compare April 26, 2019 22:01
@abayer
Copy link
Contributor Author

abayer commented May 1, 2019

Ok, new PR to jsonschema up at alecthomas/jsonschema#36 - the first thing the original PR did (keep from panicking on unnamed fields) got fixed in someone else's PR that got merged before mine, so the new PR just adds the ability to ignore types. Hopefully it'll get merged in the next couple days, I can switch to using the real version rather than my fork here, and this can go off hold.

@abayer abayer force-pushed the validate-pipeline-yaml-jenkins-x-yml branch from b6baf77 to 550e71b Compare May 3, 2019 13:10
abayer added 3 commits May 4, 2019 13:39
Also added `jx step buildpack validate`, which validates against
`jenkins-x-kubernetes` and `jenkins-x-classic` from the local clones.

Note that this depends on https://github.com/abayer/jsonschema, which
I'll try to get in a PR to the original (https://github.com/alecthomas/jsonschema).

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Specifically:
- `jx step syntax schema [--pipeline|--buildpack]`
- `jx step syntax validate pipeline`
- `jx step syntax validate buildpacks`

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
@abayer
Copy link
Contributor Author

abayer commented May 4, 2019

/hold cancel

The PR we needed is merged, so this is good to go!

@abayer abayer force-pushed the validate-pipeline-yaml-jenkins-x-yml branch from 550e71b to 210e663 Compare May 4, 2019 17:43
@rawlingsj
Copy link
Member

/lgtm

@jenkins-x-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rawlingsj

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jenkins-x-bot jenkins-x-bot merged commit 058dc85 into jenkins-x:master May 7, 2019
highlyunavailable pushed a commit to highlyunavailable/jx that referenced this pull request May 13, 2019
…enkins-x#3757)

* fix: add JSON schema validation for pipeline.yaml and jenkins-x.yml

Also added `jx step buildpack validate`, which validates against
`jenkins-x-kubernetes` and `jenkins-x-classic` from the local clones.

Note that this depends on https://github.com/abayer/jsonschema, which
I'll try to get in a PR to the original (https://github.com/alecthomas/jsonschema).

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>

* chore: New jx step syntax [command]

Specifically:
- `jx step syntax schema [--pipeline|--buildpack]`
- `jx step syntax validate pipeline`
- `jx step syntax validate buildpacks`

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>

* chore: switch to alecthomas/jsonschema now that the needed PR is merged

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
daveconde pushed a commit to daveconde/jx that referenced this pull request Apr 7, 2020
…enkins-x#3757)

* fix: add JSON schema validation for pipeline.yaml and jenkins-x.yml

Also added `jx step buildpack validate`, which validates against
`jenkins-x-kubernetes` and `jenkins-x-classic` from the local clones.

Note that this depends on https://github.com/abayer/jsonschema, which
I'll try to get in a PR to the original (https://github.com/alecthomas/jsonschema).

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>

* chore: New jx step syntax [command]

Specifically:
- `jx step syntax schema [--pipeline|--buildpack]`
- `jx step syntax validate pipeline`
- `jx step syntax validate buildpacks`

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>

* chore: switch to alecthomas/jsonschema now that the needed PR is merged

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undefined fields in jenkins-x.yml or pipeline.yaml are silently ignored
10 participants