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

azure pipeline expression ${{ else }} false positive key-duplicates #619

Open
mkieszek opened this issue Dec 28, 2023 · 2 comments
Open

Comments

@mkieszek
Copy link

mkieszek commented Dec 28, 2023

I'm using two if/else expressions in variable section of azure pipeline and yamllint is reporting a key-duplicates.
Is there any way to exclude azure pipeline expressions from linting?

Same problem was described in this issue super-linter/super-linter#3335

Provided solution, to placing a # yamllint disable-line at line above, is not very elegant.

@adrienverge
Copy link
Owner

Hello,

For the record, the referenced example is as follows:

- template: /path-to/file.yml 
    parameters:
      param1: "foo"
      ${{ if condition1 }}:
        param2: "value1"
      ${{ else }}:
        param2: "Fooccess"
      param3: "fooX"
      
      param4: "fooY"
      ${{ if condition2 }}:
        param5: "value3"
      ${{ elseif condition3 }}:
        param5: "Fooccess"
      ${{ else }}:
        param5: "Foocked :("

This is not YAML, but a Azure DevOps template that is meant to be compiled into YAML (${{ }} are then replaced with real values).

In general, a YAML linter (either PyYAML or another one) is not able to parse such a language. Here, PyYAML is able to parse the file, but correctly extract two keys with the same name "${{ else }}". It's normal that yamllint reports it: that's what we expect from the rule key-duplicates.

If it's possible to you, I would suggest linting the output of what Azure DevOps generates (that should be valid YAML), rather than the source format.

@mkieszek
Copy link
Author

mkieszek commented Jan 2, 2024

Liniting output is to late task. We are developing Azure Pipelines and want to validate during a CI stage.
I understand that the file is not a strict YAML format. But we are using yamlint because this is the best what we can get. From my perspective it would be better to be able tweak yamllint instead building, even on top of it, a new tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants