Name for matrix jobs

I figured out today that I can even use matrix jobs with contexts… sweet!

      - myorb/foo:
          some-param: false
          post-steps:
            - run: xyz $SOME_VAR
          filters:
            branches:
              only:
                - main
          matrix:
            parameters:
              context:
                - context1
                - context2

Trying to make a minor tweak, I had a question… if I run the job like this, the generated job name will be, e.g., myorb/foo-context1 and myorb/foo-context2. But let’s say I want to have it be foo-context1 etc… if I add name: foo to myorb/foo, I get name-1 and name-2 instead; ditto if I pass in `name: [“foo”].

Is there a way to control the pattern such that I can change the prefix, but not the naming pattern?

Hi @wyardley ,

This is possible by referencing the “context” parameter with the following syntax:

<< matrix.context >>

Here is a sample from your example:

workflows:
  workflow1:
    jobs:
      - myorb/foo:
          name: "foo-<< matrix.context >>"
          some-param: false
          post-steps:
            - run: xyz $SOME_VAR
          filters:
            branches:
              only:
                - main
          matrix:
            parameters:
              context:
                - context1
                - context2

This would run two jobs with the names foo-context1 and foo-context2.

Could you try this out on your end, and let me know if it works for your use-case?

Thank you!

2 Likes

@aaronclark thanks! Was hoping there was something exactly like that!

Confirm that this does exactly what I want.

1 Like

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