Skip to content

Bug with job outputs when using matrix jobs #32795

Closed
@akamoroz

Description

@akamoroz

Description

Hello, I found a bug which affected outputs when using matrix jobs.

Here an example of jobs: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#using-job-outputs-in-a-matrix-job

jobs:
  job1:
    runs-on: ubuntu-latest
    outputs:
      output_1: ${{ steps.gen_output.outputs.output_1 }}
      output_2: ${{ steps.gen_output.outputs.output_2 }}
      output_3: ${{ steps.gen_output.outputs.output_3 }}
    strategy:
      matrix:
        version: [1, 2, 3]
    steps:
      - name: Generate output
        id: gen_output
        run: |
          version="${{ matrix.version }}"
          echo "output_${version}=${version}" >> "$GITHUB_OUTPUT"
  job2:
    runs-on: ubuntu-latest
    needs: [job1]
    steps:
      # Will show
      # {
      #   "output_1": "1",
      #   "output_2": "2",
      #   "output_3": "3"
      # }
      - run: echo '${{ toJSON(needs.job1.outputs) }}'

However it shows in Gitea:

{
  "output_1": "1",
  "output_2": "",
  "output_3": ""
}

I think the issue in evaluating outputs for every matrix job:

🏁  Job succeeded
expression '${{ steps.gen_output.outputs.output_1 }}' rewritten to 'format('{0}', steps.gen_output.outputs.output_1)'
evaluating expression 'format('{0}', steps.gen_output.outputs.output_1)'
expression 'format('{0}', steps.gen_output.outputs.output_1)' evaluated to '%!t(string=)'
expression '${{ steps.gen_output.outputs.output_2 }}' rewritten to 'format('{0}', steps.gen_output.outputs.output_2)'
evaluating expression 'format('{0}', steps.gen_output.outputs.output_2)'
expression 'format('{0}', steps.gen_output.outputs.output_2)' evaluated to '%!t(string=)'
expression '${{ steps.gen_output.outputs.output_3 }}' rewritten to 'format('{0}', steps.gen_output.outputs.output_3)'
evaluating expression 'format('{0}', steps.gen_output.outputs.output_3)'
expression 'format('{0}', steps.gen_output.outputs.output_3)' evaluated to '%!t(string=3)'

Could you please fix it and provide a workaround for now?

Thanks!

Gitea Version

v1.22.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions