Workflow job with needs output from matrix?

I have a workflow building several docker images and only publishing those images if all builds succeed.

The obvious way to solve this was to have a build job with a matrix of the image names and then a publish job with the same matrix that “needs” the build job. This works fine.

However now I also want to generate outputs during build for each image that I want to re-use during the publish job for the same image. I know that I can work around this using artefacts but if these weren’t matrix jobs I could just do it using outputs.

Is there a special syntax to do access outputs from a matrix job or are matrix jobs simply incapabl of generating outputs? I can’t find any explanation of this in the docs and it doesn’t seem like the outputs could be named dynamically since they need to be explicitly defined at the job level.

Hey Alan, matrix jobs can set outputs but they will overwrite each other. The last one wins. As a workaround, you can add a unique parameter for each matrix job and use that to set outputs with different names: [BUG] Jobs output should return a list for a matrix job - #15 by Simran-B

1 Like

Hey thanks Simran, looks like I’ll have to duplicate the matrix list for the outputs then. That solution seems obvious in hindsight but didn’t occur to me.