Gitlab - gitlab-ci.yml 无法识别 7zip 命令
Gitlab - gitlab-ci.yml is not recognizing 7zip command
我刚开始使用 Gitlab 的 CI/CD 功能。我需要为已发布的项目创建 zip 文件。 脚本的最后两行 应该可以发挥作用。
build:
stage: build
script:
- echo "Testing CI CD"
- git clone https://gitlab.io/common-dependencies.git
- git clone https://gitlab.io/sitecore-nuget.git
- nuget restore
- msbuild Common.SC.sln /property:Configuration=Release
/p:PublishProfile=C:\CICDArtifacts\Artifacts_Release.pubxml
- cd .\bin\Release
- '"C:\Program Files-Zipz.exe" a C:\CICDArtifacts$CI_PROJECT_NAME-$CI_JOB_ID.zip'
但是当构建触发时,我收到以下错误。
然而,当我在 Gitlab runner 中执行以下命令时,它运行完美。
"C:\Program Files-Zipz.exe" a C:\CICDArtifacts\commonProject.zip'
看来我在这里遗漏了什么。请帮助我理解,gitlab runner 如何理解 7z
、echo
、msbuild
等命令
请注意,7zip 已安装,位于
C:\程序Files-Zipz.exe
非常感谢您的帮助。
how gitlab runner understands commands like echo, msbuild etc
如果他们的父文件夹在%PATH%
.
中应该可以理解
如果 运行 不带引号的命令不起作用,请尝试替代脚本行:
- cmd /C "\""C:\Program Files-Zipz.exe" a C:\CICDArtifacts\commonProject.zip"
没有引号的形式是:没有单引号:
- "C:\Program Files-Zipz.exe" a C:\CICDArtifacts\commonProject.zip
我已经使用以下步骤解决了问题。
更新了指向 7z.exe 路径的 %PATH%
环境变量。
更新脚本如下。
'- 7z 一个 C:\CICDArtifacts\$CI_PROJECT_NAME-$CI_JOB_ID.zip'
重新启动 Gitlab runner,因为 Gitlab 在更新环境变量后无法识别 7z
命令。
希望对大家有所帮助。
使用
- powershell -Command executable.exe arguments
这个命令对我有用,可以在 gitlab yaml 中启动一个 exe。
我刚开始使用 Gitlab 的 CI/CD 功能。我需要为已发布的项目创建 zip 文件。 脚本的最后两行 应该可以发挥作用。
build:
stage: build
script:
- echo "Testing CI CD"
- git clone https://gitlab.io/common-dependencies.git
- git clone https://gitlab.io/sitecore-nuget.git
- nuget restore
- msbuild Common.SC.sln /property:Configuration=Release
/p:PublishProfile=C:\CICDArtifacts\Artifacts_Release.pubxml
- cd .\bin\Release
- '"C:\Program Files-Zipz.exe" a C:\CICDArtifacts$CI_PROJECT_NAME-$CI_JOB_ID.zip'
但是当构建触发时,我收到以下错误。
然而,当我在 Gitlab runner 中执行以下命令时,它运行完美。
"C:\Program Files-Zipz.exe" a C:\CICDArtifacts\commonProject.zip'
看来我在这里遗漏了什么。请帮助我理解,gitlab runner 如何理解 7z
、echo
、msbuild
等命令
请注意,7zip 已安装,位于 C:\程序Files-Zipz.exe
非常感谢您的帮助。
how gitlab runner understands commands like echo, msbuild etc
如果他们的父文件夹在%PATH%
.
如果 运行 不带引号的命令不起作用,请尝试替代脚本行:
- cmd /C "\""C:\Program Files-Zipz.exe" a C:\CICDArtifacts\commonProject.zip"
没有引号的形式是:没有单引号:
- "C:\Program Files-Zipz.exe" a C:\CICDArtifacts\commonProject.zip
我已经使用以下步骤解决了问题。
更新了指向 7z.exe 路径的
%PATH%
环境变量。更新脚本如下。
'- 7z 一个 C:\CICDArtifacts\$CI_PROJECT_NAME-$CI_JOB_ID.zip'
重新启动 Gitlab runner,因为 Gitlab 在更新环境变量后无法识别
7z
命令。
希望对大家有所帮助。
使用
- powershell -Command executable.exe arguments
这个命令对我有用,可以在 gitlab yaml 中启动一个 exe。