Run same job multiple times does not work

I’m trying to run the same job multiple times.
I took the example from the official documentation (see https://circleci.com/docs/2.0/reusing-config/#invoking-the-same-job-multiple-times) (added the jobs section).

version: 2.1
jobs:
  loadsay:
    machine: true
    steps:
      - run: echo "hi"

  sayhello:
    machine: true
    steps:
      - run: echo "hello"

  saygoodbye:
    machine: true
    steps:
      - run: echo "bye"

workflows:
  version: 2
  build:
    jobs:
      - loadsay
      - sayhello:
          requires:
            - loadsay

      - sayhello:
          name: SayHelloChad

      - saygoodbye:
          requires:
            - SayHelloChad

The workflow does not start and return the following error:

We weren’t able to start this workflow.
Encountered errors trying to create workflows from this config: Config does not conform to schema: {:workflows {:build {:jobs [nil nil {:sayhello {:name disallowed-key}} nil]}}}

For more examples see the Workflows documentation.

Any idea why?

Just guessing here, does the version applied to your workflows have to match up with the version of the doc?

I have tried to set workflows version to 2.1 but it says “Unsupported or missing workflows config version”.
That makes sense since there are no doc info referring to any 2.1 version for workflows.

The weird thing is that the local circleci client says that the config file is valid… but then it fails when running it on circleci

$ circleci config validate
Config file at .circleci/config.yml is valid

If you temporarily remove the second sayhello entry in the workflow, does that help? I wondered whether this section produces an associative array with (clashing) keys, but in fact it produces an indexed array of objects, so in YAML terms it would seem to be valid.

(You probably know the 2.1 format is experimental at present, this issue may be evidence of that!)

Just by removing name from the 3rd job things work as expected. Sound as CircleCI bug.

As temporary workaround I have abused of YAML references and created two jobs as follows:

version: 2.1
jobs:
  loadsay:
    machine: true
    steps:
      - run: echo "hi"

  sayhello: &sayhello_ref
    machine: true
    steps:
      - run: echo "hello"
      
  SayHelloChad:
    <<: *sayhello_ref     

  saygoodbye:
    machine: true
    steps:
      - run: echo "bye"

workflows:
  version: 2
  build:
    jobs:
      - loadsay
      - sayhello:
          requires:
            - loadsay

      - SayHelloChad

      - saygoodbye:
          requires:
            - SayHelloChad
1 Like

I strongly suspect the issue here is you don’t have Build Processing enabled in your project settings (under “Advanced” on your project’s settings page). Your original config runs fine for me when I have that on. The bug in this case may be that we need a much better error handling when passing 2.1 config without build processing on.

1 Like

Wow! I missed that! It worked! Thanks!

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