Passing an environment variable to 'parameters' in the continuation/continue command does not work

Hello,

I have recently started using dynamic configs since there are multiple issues which this feature will fix in our ci.

The latest problem I am experiencing is that I am trying to pass a dynamic json object to the continuation/continue for example:

version: 2.1
setup: true
orbs:
  continuation: circleci/continuation@0.2.0
jobs:
  Execute_Workflow:
    executor: continuation/default
    steps:
      - checkout
      - run:
          name: Trying to set a dynamic pipeline var
          command: |
            hash="a87joe90rqhidaids23" # just an example, hash will be generated based on more complex logic
            echo "extra_parameters='{ \"backend_hash\"":" \"$hash\" }'" >> $BASH_ENV
            source $BASH_ENV
            echo $extra_parameters
      - continuation/continue:
          configuration_path: .circleci/config.packed.yml
          parameters: |
            $extra_parameters
workflows:
  Execute_Workflow:
    jobs:
      - Execute_Workflow

The problem is I am getting the error PARAMETERS aren't valid json in the setup phase in the continuation command.
If I were to use

          parameters: |
            { "backend_hash": "a87joe90rqhidaids23" }

everything works as expected but as stated before a87joe90rqhidaids23 is generated dynamically.

Note that the following does not work either:

          parameters: |
            { "backend_hash": "$PREVIOUSLY_EXPORTED_ENV_VAR" }

How could I bypass this?

Thanks in advance

I am using the workaround presented here: Continuation parameters w/ evaluated environmental variables

so many workarounds…

Also check out the swissknife orb. I have built it in a nice continue which lets you pass params in to the continue config.

https://circleci.com/developer/orbs/orb/roopakv/swissknife#jobs-filter-and-continue

:wave: Hi @dragosMC91,

I think the issue in your initial configuration stems from the double-quotes around the : character.

Both the below syntaxes will work:

  • echo "extra_parameters='{ \"backend_hash\" : \"$hash\" }'" >> $BASH_ENV

  • echo "extra_parameters='{ "backend_hash" : "'"$hash"'" }'" >> $BASH_ENV (around $hash: double-quote/single-quote/double-quote)

Hello, thank you for your help, I got it to work eventually :smiley:

1 Like

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