我正在 Jenkins 中执行一个 Windows 批处理文件。部分脚本查找匹配的文件*.cover.xml
并在每个文件上运行一个外部程序。该批处理文件的相关部分如下所示
SETLOCAL ENABLEDELAYEDEXPANSION
SET project_path=\\home\Sonar\8.1
PUSHD %project_path%
FOR /R %%i IN (*.cover.xml) do ncxc.exe %%i
POPD
当我将 设置project_path
为本地路径时,例如D:\MyProj\
,它可以完美运行。当我像上面那样使用 UNC 路径时,就会出现问题。第一次运行时,它通过了。之后每次都失败!
“ncxc.exe”不是内部或外部命令、可运行程序或批处理文件。
我DIR
在脚本末尾运行,目录为空!Jenkins 服务以域用户身份运行,该copy
命令适用于网络资源。并将PUSHD
UNC 路径安装到驱动器号。
编辑- 整个批处理文件也以同样的方式失败
set deployment_path=d:\deployment\
SETLOCAL ENABLEDELAYEDEXPANSION
set project_path=Z:\8.1\
pushd %project_path%
set some_path=%CD%
copy %deployment_path%\sppg.exe %CD%\sppg.exe /y
copy %deployment_path%\sonar_main.bat %CD%\sonar_main.bat /y
copy %deployment_path%\utils_all.bat %CD%\Utils\utils.all.bat /y
copy %deployment_path%\dunit2surefire.xsl %CD%\HCPC\dunit2surefire.xsl /y
copy %deployment_path%\xslt2xml.exe %CD%\HPC\xslt2xml.exe /y
copy %deployment_path%\sonar_delphi_all.bat %CD%\HPC\sonar_delphi_all.bat /y
copy %deployment_path%\xslt.bat %CD%\HCPC\Client\xslt.bat /y
copy %deployment_path%\xslt.bat %CD%\HCPC\Server\xslt.bat /y
copy %deployment_path%\ncxc.exe %CD%\ncxc.exe /y
copy %deployment_path%\ncover-converter.bat %CD%\ncover-converter.bat /y
ncxc.exe %CD%
popd
pushd %project_path%
sppg.exe "%CD%" ./Output_AutomatedBuild/TestsResults/Coverage/*.cover.xml
dir Z:
sonar_main.bat
popd