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

Schema validation errors for dynamic job name within azure pipeline #169

Open
robertaves opened this issue Oct 24, 2022 · 3 comments
Open
Labels
azure-schema-lies The Azure Pipelines Schema is at it again enhancement New feature or request

Comments

@robertaves
Copy link

Problem:
When using expressions for job names we get a Schema validation error.

parameters:
  - name: name
    type: string

stages:
  - stage: aws
    displayName: AWS
    jobs:
      - job: "${{ parameters.name }}"

Error:
image

Setup:

repos:
    - repo: https://github.com/python-jsonschema/check-jsonschema
      rev: 0.18.4
      hooks:
        - id: check-azure-pipelines
          files: '^.azure/.*\.yml'

Note this also errors out in the Azure Server Lang plugin as well as it can't validate the schema
image

@sirosen
Copy link
Member

sirosen commented Oct 24, 2022

I don't know that there's anything the checker can do in this case out of the box. The azure pipelines schema doesn't really describe what those files can contain.

I don't want that to be my final answer -- even weak validation is worth something -- but it is my starting point.

I'm thinking about how to work around this without trying to really implement their expression language (that seems very fraught to me). What if I offered an option to replace strings prior to validation, such that you could write in your config

  add_args: ["--replace-string", "${{ parameters.name }}", "dummy-job-name"]

?

Would that be sufficient and interesting to you as a user?

I might not want to make it a CLI option, perhaps config instead, but that would be the idea of it.
Or it might be nicer to let you specify jsonpath to the value which needs replacement.

@sirosen sirosen added enhancement New feature or request azure-schema-lies The Azure Pipelines Schema is at it again labels Oct 24, 2022
@robertaves
Copy link
Author

Json path might be cleaner via a config as our pipelines are utilizing the templated job names quite a bit.. Some come from variables, some come from parameters so replace-string may be hard to scale. If we could some how ignore values in certain json paths it might be more flexible and scalable.

@sirosen
Copy link
Member

sirosen commented Oct 25, 2022

If we could some how ignore values in certain json paths it might be more flexible and scalable.

I wish we could. I agree that it would work better from a user-perspective: you get an error from the linting and you effectively say "ignore that error".
Unfortunately, I think that would require modifying the schema, and there's no reliable way to do that with nested structures like oneOf.

I'll try to make time soon to work on some kind of replacer config, since that's the best workaround I can come up with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-schema-lies The Azure Pipelines Schema is at it again enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants