Setting a job parameter default to another parameter fails silently

jobs:
  my-job:
    parameters:
      first-param:
        type: string
      second-param:
        type: string
        default: << parameters.first-param >>

expectation:
i would expect the second-param to take on the value of the first-param if not specified.
alternatively, i could expect a syntax error.

actual:
instead, neither of these things happen, and the syntax fails silently.

1 Like

A work-around we found is to use bash to substitute empty parameter with a mandatory one.
Our context is a command, but there is no reason for it not to work with jobs

commands:
    my-cmd:
        parameters:
            foo:  # always set
                type: string
            bar:  # Optional, takes foo as default
                type: string
                default: ''
            steps:
            - run:
                name: lint
                command: |
                    # substitute by foo only if bar is empty
                    bar_or_foo=`[ -n "<< parameters.bar >>" ] && echo "<< parameters.bar >>" || echo "<< parameters.foo >>"`
                    whatever $bar_or_foo

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.