Passing parameters down from project workflow -> orb job -> orb command leaves parameter empty

config
orbs
#1

I defined an orb with two parameterized jobs. From my workflow I refer to these jobs and pass on some parameters.

myorb/job1 directly uses its parameter in a bash command, which works fine.
myorb/job2 again passes its parameter to an orb command which directly uses it in a bash command, but now the parameter has become empty

Is passing on parameters like this supported? The chain circleci workflow -> orb job -> orb command seems to be problematic.

#2

I found a work-around using temporary environment variables.

Here’s what I thought should work, but doesn’t:

deploy-defaults: &JOB_DEPLOY_DEFAULTS
  parameters:
    mvn-deploy-command:
      type: string
      default: echo "mvn-deploy-command not provided" 1&>&2 && exit 1

jobs:
  deploy-patch-version:
    <<: *JOB_DEPLOY_DEFAULTS
    steps:
      - deploy:
          mvn-deploy-command: << parameters.mvn-deploy-command >>

commands:
  deploy:
    parameters:
      mvn-deploy-command:
        type: string
    steps:
      - run:
          command: << parameters.mvn-deploy-command >>

And here’s the workaround that does work:

deploy-defaults: &JOB_DEPLOY_DEFAULTS
  parameters:
    mvn-deploy-command:
      type: string
      default: echo "mvn-deploy-command not provided" 1&>&2 && exit 1
  environment:
      TMP_PARAM1: << parameters.mvn-deploy-command >>

jobs:
  deploy-patch-version:
    <<: *JOB_DEPLOY_DEFAULTS
    steps:
      - deploy:
          mvn-deploy-command: $TMP_PARAM1

commands:
  deploy:
    parameters:
      mvn-deploy-command:
        type: string
    steps:
      - run:
          command: << parameters.mvn-deploy-command >>

The first one should be a bug, right?

1 Like
#3

Hi @bbottema!

This should definitely work. Is it possible you had a typo or error somewhere? Passing a parameter to a job, which passes it to a command, is a very common orb pattern that I use all the time.

I wonder if the problem you’re having is because your command is named deploy? That’s a special name in our system:

https://circleci.com/docs/2.0/configuration-reference/#deploy

Have you tried with a different command name?

Thanks!

1 Like
#4

Hi @rose, yes renaming deploy to something else actually solved it. Weird! Thanks for the tip.

2 Likes
closed #5

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