mschuett/yaml-shellcheck

Gitlab spec:inputs are breaking the script

Closed this issue · 3 comments

I am using this for linting in some Gitlab pipelines and just noticed that on newer jobs which use spec:inputs it's breaking since it's technically two YAML files in one.

More information about spec:inputs:
https://docs.gitlab.com/ee/ci/yaml/inputs.html

Error:

Traceback (most recent call last):
  File "/root/yaml-shellcheck/yaml_shellcheck.py", line 440, in <module>
    main()
  File "/root/yaml-shellcheck/yaml_shellcheck.py", line 427, in main
    result = {filename: read_yaml_file(filename)}
  File "/root/yaml-shellcheck/yaml_shellcheck.py", line 368, in read_yaml_file
    data = yaml.load(f)
  File "/usr/local/lib/python3.9/site-packages/ruamel/yaml/main.py", line 451, in load
    return constructor.get_single_data()
  File "/usr/local/lib/python3.9/site-packages/ruamel/yaml/constructor.py", line 114, in get_single_data
    node = self.composer.get_single_node()
  File "_ruamel_yaml.pyx", line 718, in ruamel.yaml.clib._ruamel_yaml.CParser.get_single_node
ruamel.yaml.composer.ComposerError: expected a single document in the stream
  in "./Jobs/Trigger.gitlab-ci.yml", line 13, column 1
but found another document
  in "./Jobs/Trigger.gitlab-ci.yml", line 52, column 1

Very cut down example pipeline:

spec:
  inputs:
    target:
      type: string
      description: The Target URL
---
trigger:
  stage: .post
  image: $CI_REGISTRY/pipeline-components/helperimages:alpine-utils
  script:
    - |
      curl --location $[[ inputs.target ]]

Thank you for the report and the example.
I finally found some time to look into this.

Did a quick test of the new version. Doesn't throw errors anymore. :) Thanks!

Thank you for testing :)