bounty将在2天后过期。回答此问题可获得+50声望奖励。AlexS希望引起更多人对此问题的关注:我相信问题出在从powershell访问GITHUB_PATH上。我检查了用户权限,我确定在访问GITHUB_PATH时登录的用户及其计算机上的管理员成员。
我有以下工作流程
name: Test set path
on:
workflow_dispatch:
jobs:
test-cross-aws:
runs-on: [self-hosted, '${{ matrix.platform.os }}', x64, '${{ matrix.platform.label }}']
#runs-on: windows-latest
strategy:
matrix:
platform: [{ os: windows, label: wix-aws-windows-test }]
steps:
- name: create fake batchfile
if: always()
run: |
mkdir testfolder
echo "@echo off" | Out-File -FilePath testfolder/testbatch.bat -Encoding utf8
echo "echo SOMETHING" | Out-File -FilePath testfolder/testbatch.bat -Encoding utf8
- name: add path
if: always()
run: echo "$pwd\testfolder;" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: run custom binary with path
if: always()
run: testbatch.bat
它在常规的github action windows runner上工作正常。但在基于此image构建的自托管github runner上失败。
testbatch.bat : The term 'testbatch.bat' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\actions-runner\_work\_temp\744d9b45-8f99-4db5-ba7d-b95aad4dde97.ps1:2 char:1
+ testbatch.bat
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (testbatch.bat:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException
Error: Process completed with exit code 1.
Github运行器版本是2.303.0 Windows我使用的是Windows 2022数据中心。
1条答案
按热度按时间ie3xauqp1#
我怀疑你在运行outdated version of the GitHub Runner that doesn't support the new syntax to add variables to the path。
如果您使用的是自托管运行器,请确保它们已更新到版本2.273.1或更高版本。
我刚刚在Windows 11 Pro上的自托管代理上运行了此工作流(进一步稍微简化),没有失败:
它成功了,没有任何问题:
要检查
$env:GITHUB_PATH
的内容,只需将其内容写入控制台:GITHUB_
环境变量指向一个临时文件,该文件在步骤完成后由运行程序读取。环境变量为我们提供了一种方法,使我们不必知道文件的名称即可知道文件的名称。