Step outputs sometimes not found #601

Open
opened 2024-09-13 10:19:41 +00:00 by greuelpirat · 4 comments
greuelpirat commented 2024-09-13 10:19:41 +00:00 (Migrated from gitea.com)

Gitea Version: 1.22.0

in a workflow step sometimes the step output is not found:

name: IssueDemo
on: [push]

jobs:
  Build:
    runs-on: [msbuild]
    outputs:
      VERSION: ${{ steps.read-version.outputs.VERSION }}
    steps:
      - name: Check out repository code
        uses: actions/checkout@v4
        with:
          path: Sources
      - name: Read VERSION
        id: read-version
        run: >
          'VERSION=' + (Get-Content Sources\VERSION) + '.${{ gitea.run_number }}'
          | Out-File -FilePath $env:GITHUB_OUTPUT -Append
          ; Get-Content $env:GITHUB_OUTPUT
      - run: Write-Output ${{ steps.read-version.outputs.VERSION }}

sometimes when the same build script runs ${{ steps.read-version.outputs.VERSION }} is empty but not always.

working:
image.png

failing:
image.png

Gitea Version: 1.22.0 in a workflow step sometimes the step output is not found: ``` name: IssueDemo on: [push] jobs: Build: runs-on: [msbuild] outputs: VERSION: ${{ steps.read-version.outputs.VERSION }} steps: - name: Check out repository code uses: actions/checkout@v4 with: path: Sources - name: Read VERSION id: read-version run: > 'VERSION=' + (Get-Content Sources\VERSION) + '.${{ gitea.run_number }}' | Out-File -FilePath $env:GITHUB_OUTPUT -Append ; Get-Content $env:GITHUB_OUTPUT - run: Write-Output ${{ steps.read-version.outputs.VERSION }} ``` sometimes when the same build script runs `${{ steps.read-version.outputs.VERSION }}` is empty but not always. working: <img width="684" alt="image.png" src="attachments/de30940e-170c-4a9a-af8d-ca9e35c8f85a"> failing: <img width="676" alt="image.png" src="attachments/c4acca62-4cd9-4aa5-a1da-e440c436413b">
schallbert commented 2024-09-17 20:15:32 +00:00 (Migrated from gitea.com)

Hey. Wildly guessing here, but when reading related documentation my interpetation would be that outputs are intended to be used in subsequent workflows, not necessarily the one they are generated in:

"[...] available to all downstream jobs in the caller workflow [...]" - on.workflow_call.outputs

So this being a script rather than a to-be-compiled procedure, reading the output variable might take place even before it is written.

To solve your problem, I see two possibilities:

  1. Put your commands in separate jobs if you'd like to stick to the outputs mechanism (using the above link you will easily find examples for this)
  2. Use environment variables as documented in the writing-workflows guide.

Hope I could help
Schallbert

Hey. Wildly guessing here, but when [reading related documentation](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onworkflow_calloutputs) my interpetation would be that `outputs` are intended to be used in *subsequent* workflows, not necessarily the one they are generated in: > "[...] available to all downstream jobs in the caller workflow [...]" - on.workflow_call.outputs So this being a script rather than a to-be-compiled procedure, reading the `output` variable might take place even before it is written. To solve your problem, I see two possibilities: 1. Put your commands in separate jobs if you'd like to stick to the `outputs` mechanism (using the above link you will easily find examples for this) 2. Use environment variables as documented in the [writing-workflows guide](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables). Hope I could help _Schallbert_
greuelpirat commented 2024-09-18 06:31:15 +00:00 (Migrated from gitea.com)

Thank you very much.

In our real build script we needed the value in a follow-up step as well as in a follow-up job. That's why I thought the variable output would be enough.

I guess I need to set it as an output parameter as well as an environmental variable. I will try that. Thanks again!

Thank you very much. In our real build script we needed the value in a follow-up step as well as in a follow-up job. That's why I thought the variable output would be enough. I guess I need to set it as an output parameter as well as an environmental variable. I will try that. Thanks again!
Zettat123 commented 2024-10-15 07:26:12 +00:00 (Migrated from gitea.com)

It looks like this issue has been resolved. I will close this issue. Please reopen it if you need more help.

It looks like this issue has been resolved. I will close this issue. Please reopen it if you need more help.
hakito commented 2024-11-08 06:57:50 +00:00 (Migrated from gitea.com)

I don't think this is resolved. According to github workflow documentation it should be possible to hand over values between steps within a job.

Please re-open!

I don't think this is resolved. According to [github workflow documentation](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-output-parameter) it should be possible to hand over values between steps within a job. Please re-open!
Sign in to join this conversation.