mathieu-lemay/pipeline-runner

Yaml validation problem

Closed this issue · 3 comments

When variables are declared $VAR instead of ${VAR} code gives validation errors. Below sample of valid in bitbucket validator but it throwing valid string errors.

    - step: &deploy
        script:
          - pipe: atlassian/scp-deploy:1.2.1
            variables:
              USER: $USER
              SERVER: $SERVER
              REMOTE_PATH: $REMOTE_PATH
              LOCAL_PATH: 'test.zip'
              EXTRA_ARGS: [ "-P", $PORT ]
          - pipe: atlassian/ssh-run:0.4.1
            variables:
              SSH_USER: $USER
              MODE: 'command'
              SERVER: $SERVER
              PORT: $PORT
              COMMAND: cd $REMOTE_PATH && unzip -o test.zip -d ./ && rm test.zip
pipelines.branches.dev.7.StepWrapper.step.script.0.str
  Input should be a valid string [type=string_type, input_value={'pipe': 'atlassian/scp-d...ARGS': ['-P', '$PORT']}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/string_type
pipelines.branches.dev.7.StepWrapper.step.script.0.Pipe.variables.EXTRA_ARGS
  Input should be a valid string [type=string_type, input_value=['-P', '$PORT'], input_type=list]
    For further information visit https://errors.pydantic.dev/2.7/v/string_type

Thanks for creating the issue. Just a quick note, this is not related to $VAR vs ${VAR}. The actual issue is this line:

EXTRA_ARGS: [ "-P", $PORT ]

Normally, the variables of a pipe should be strings, but in your case, you have a list of strings there. I think you can workaround this issue temporarily by changing that line to

EXTRA_ARGS: '[ "-P", $PORT ]'

In any case, if that step works as in in Bitbucket, I will fix my tool to support this shortly.

@qbejs I've merged a fix for parsing variables that are lists, as well as injecting them properly in the pipe.

However, you will likely encounter another issue with ssh keys when you try to actually run those pipes. I'll open an issue for that and will try to fix it in a timely manner.

@qbejs I've released a version 0.4.1 which should fix your problem and the 2nd one I mentioned.