admin管理员组文章数量:1397110
I have the following 2 jobs. I have confirmed that the assignment to the variables in each step of the Set batch indicator job is valid and was able to echo out what I expected. However when I try to set it to the GITHUB_OUTPUT to refer in the 2nd step, it doesn't seem to work. The self hosted runner is on Windows 2022 and I need to use powershell for the shell (not powershell core, shell:pwsh). I have tried the below implementation of setting to GITHUB_OUTPUT as well as
echo "variable=$variable" >> GITHUB_OUTPUT
and
echo "variable=$variable" >> env:GITHUB_OUTPUT
I have tried them both with and without quotations around the GITHUB_OUTPUT
set-batch-indicator:
runs-on: self-hosted
environment: ${{inputs.environment}}
needs: [build, test]
steps:
- name: Set Config Source Batch Identifier
id: batch-config-source
run: |
$ConfigSrcBatch = "${{ vars.CODE_SOURCE_BATCH }}".replace("BATCH","${{ inputs.batchToDeploy }}")
echo "ConfigSourceBatch=$ConfigSourceBatch" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
shell: powershell
- name: Set Config Target Batch Identifier
id: batch-config-target
run: |
$ConfigTrgtBatch = "${{ vars.CONFIG_SOURCE_BATCH }}".replace("BATCH","${{ inputs.batchToDeploy }}")
echo "ConfigTargetBatch=$ConfigTargetBatch" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
shell: powershell
- name: Set Code Source Batch Identifier
id: batch-code-source
run: |
$CodeSourceBatch = "${{ vars.CONFIG_TARGET_BATCH }}".replace("BATCH","${{ inputs.batchToDeploy }}")
echo "CodeSourceBatch=$CodeSourceBatch" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
shell: powershell
- name: Set Distribution Path Batch Identifier
id: batch-dist-path
run: |
$DistributionPathBatch = "${{ vars.DISTRIBUTION_PATH_BATCH }}".replace("BATCH","${{ inputs.batchToDeploy }}")
echo "DistributionPathBatch=$DistributionPathBatch" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
echo "Test='t'" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
shell: powershell
- name: Debug GITHUB_OUTPUT
run: |
Get-Content $env:GITHUB_OUTPUT
shell: powershell
stage:
runs-on: self-hosted
environment: ${{inputs.environment}}
needs: [build, test, set-batch-indicator]
steps:
- name: Debug GITHUB_OUTPUT
run: |
Get-Content $env:GITHUB_OUTPUT
shell: powershell
- name: Confirm Batch Identifier insertion
run: |
echo ${{ needs.set-batch-indicator.outputs.ConfigSourceBatch }}
echo ${{ needs.set-batch-indicator.outputs.ConfigTargetBatch }}
echo ${{ needs.set-batch-indicator.outputs.CodeSourceBatch }}
echo ${{ needs.set-batch-indicator.outputs.DistributionPathBatch }}
I tried to debug this a bit with get-content but the output is just empty. Even with my echo "Test='t'"
line it is empty which makes no sense to me.
I have the following 2 jobs. I have confirmed that the assignment to the variables in each step of the Set batch indicator job is valid and was able to echo out what I expected. However when I try to set it to the GITHUB_OUTPUT to refer in the 2nd step, it doesn't seem to work. The self hosted runner is on Windows 2022 and I need to use powershell for the shell (not powershell core, shell:pwsh). I have tried the below implementation of setting to GITHUB_OUTPUT as well as
echo "variable=$variable" >> GITHUB_OUTPUT
and
echo "variable=$variable" >> env:GITHUB_OUTPUT
I have tried them both with and without quotations around the GITHUB_OUTPUT
set-batch-indicator:
runs-on: self-hosted
environment: ${{inputs.environment}}
needs: [build, test]
steps:
- name: Set Config Source Batch Identifier
id: batch-config-source
run: |
$ConfigSrcBatch = "${{ vars.CODE_SOURCE_BATCH }}".replace("BATCH","${{ inputs.batchToDeploy }}")
echo "ConfigSourceBatch=$ConfigSourceBatch" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
shell: powershell
- name: Set Config Target Batch Identifier
id: batch-config-target
run: |
$ConfigTrgtBatch = "${{ vars.CONFIG_SOURCE_BATCH }}".replace("BATCH","${{ inputs.batchToDeploy }}")
echo "ConfigTargetBatch=$ConfigTargetBatch" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
shell: powershell
- name: Set Code Source Batch Identifier
id: batch-code-source
run: |
$CodeSourceBatch = "${{ vars.CONFIG_TARGET_BATCH }}".replace("BATCH","${{ inputs.batchToDeploy }}")
echo "CodeSourceBatch=$CodeSourceBatch" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
shell: powershell
- name: Set Distribution Path Batch Identifier
id: batch-dist-path
run: |
$DistributionPathBatch = "${{ vars.DISTRIBUTION_PATH_BATCH }}".replace("BATCH","${{ inputs.batchToDeploy }}")
echo "DistributionPathBatch=$DistributionPathBatch" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
echo "Test='t'" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
shell: powershell
- name: Debug GITHUB_OUTPUT
run: |
Get-Content $env:GITHUB_OUTPUT
shell: powershell
stage:
runs-on: self-hosted
environment: ${{inputs.environment}}
needs: [build, test, set-batch-indicator]
steps:
- name: Debug GITHUB_OUTPUT
run: |
Get-Content $env:GITHUB_OUTPUT
shell: powershell
- name: Confirm Batch Identifier insertion
run: |
echo ${{ needs.set-batch-indicator.outputs.ConfigSourceBatch }}
echo ${{ needs.set-batch-indicator.outputs.ConfigTargetBatch }}
echo ${{ needs.set-batch-indicator.outputs.CodeSourceBatch }}
echo ${{ needs.set-batch-indicator.outputs.DistributionPathBatch }}
I tried to debug this a bit with get-content but the output is just empty. Even with my echo "Test='t'"
line it is empty which makes no sense to me.
1 Answer
Reset to default 0You have to set outputs at the job level:
set-batch-indicator:
runs-on: self-hosted
environment: ${{ inputs.environment }}
needs: [build, test]
outputs:
ConfigSourceBatch: ${{ steps.batch-config-source.outputs.ConfigSourceBatch }}
# etc.
steps:
- # ...
Also, the PowerShell syntax to set an output, according to the docs, is this:
"SELECTED_COLOR=green" >> $env:GITHUB_OUTPUT
本文标签: powershellWorkflow outputs not being saved or readStack Overflow
版权声明:本文标题:powershell - Workflow outputs not being saved or read - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744135001a2592356.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论