Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 3

Matrix variable does not work in needs keyword

Solved! Go to Solution.

I have a build matrix over a certain amount of build types. Then I want to create a job that tests those builds but each test job depends on the build of the same type so I tried:


      type: [normal, extra, nox]
  needs: build-${{ matrix.type }}

However this results in an error saying

Unrecognized named-value: 'matrix'.


Is there a way to create a template like this given we cannot templatize the needs keyword?

2 Replies
GitHub Partner
Message 2 of 3

Re: Matrix variable does not work in needs keyword

Github workflow yml doesn’t support use ${{matrix.xx}} in needs keyword. I would suggest you to specific all jobs name into the matrix job > needs keyword.

For example, you have jobs: build-normal , build-extra and build-nox.

In test job with matrix, set

needs: [build-normal, build-extra, build-nox]

Then the matrix jobs will start after all the dependences jobs completed.

Copilot Lvl 3
Message 3 of 3

Re: Matrix variable does not work in needs keyword

That will work but it's not perfect as it will delay the workflow since if build-normal is faster to run than build-extra, test-normal should start straight after build-normal and not only after all build types have finished. I understand this is a limitation and therefore will accept your answer.