我正在使用 GitHub Actions 和安装在 Windows 2019 服务器上的自托管代理设置 CI/CD 管道。
我面临的问题是 action actions/checkout@v2 无法签出 repo 并完全解压缩它。当我说“完全解压缩”时,我的意思是目标文件夹中有一些文件在停止之前设法解压缩。
从日志:
Run actions/checkout@v2
Syncing repository: Syd/ExternWebb
Getting Git version info
Deleting the contents of 'C:\actions-runner\_work\ExternWebb\ExternWebb'
The repository will be downloaded using the GitHub REST API
To create a local Git repository instead, add Git 2.18 or higher to the PATH
Downloading the archive
Writing archive to disk
Extracting the archive
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\actions-runner\_work\ExternWebb\ExternWebb\b3193a49-e100-4cbd-81c9-6bd23ff47313.tar.gz', 'C:\actions-runner\_work\ExternWebb\ExternWebb\b3193a49-e100-4cbd-81c9-6bd23ff47313')"
Exception calling "ExtractToDirectory" with "2" argument(s): "Could not find a part of the path 'C:\actions-runner\_wor
k\ExternWebb\ExternWebb\b3193a49-e100-4cbd-81c9-6bd23ff47313\Syd-ExternWebb-77d0427f54bc3e4d6694
f0719ca9fe3ab3be3706\ExternWebb.Library\Custom\Plugins\DomainRedirectModule\DomainRedirectConfigurationCollection
.cs'."
At line:1 char:111
+ ... catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\a ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : DirectoryNotFoundException
Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
我尝试在本地自托管代理上运行相同的操作,没有任何问题。
一篇 reddit帖子建议可以通过通过 Git 获取 repo 来缓解错误,并在日志中指出以下线索:
The repository will be downloaded using the GitHub REST API
To create a local Git repository instead, add Git 2.18 or higher to the PATH
我尝试安装 Git v.2.30 并将其添加到 PATH 中,但由于某种原因,该操作仍通过 GIT API 下载存储库。我不知道是否需要重新启动服务器,但 git 命令在 Powershell 中可用。
我猜这就是为什么本地自托管代理(可以访问 GIT)可以签出 repo,但在服务器上运行的代理不能。
这是工作流 yml 文件:
name: Build Stage
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
jobs:
build:
runs-on: [self-hosted, stage]
env:
CONFIG: Stage
BUILD_FOLDER: _build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checking out source code
uses: actions/checkout@v2
任何见解都值得赞赏。