Jenkins管道sh失败,并在Windows上“无法运行程序nohup”
我有Windows 10,我想使用bash for Windows的Jash从Jenkins管道在Jenkinsfile中执行sh命令,但是它不起作用
在Jenkins管道中,我处于以下阶段:
stage('sh how to') { steps {
sh 'ls -l'
}
}
错误消息是:
[C:\ Program Files(x86)\ Jenkins \ workspace \
pipelineascode]运行外壳程序脚本无法运行程序“ nohup”(在目录“ C:\ Program Files(x86)\ Jenkins \
workspace \ pipelineascode”中):CreateProcess error = 2 ,不可思议的特殊性
我尝试使用更改Jenkins parameter-> shell可执行文件
C:\ Windows \ System32 \ bash.exe
但同样的错误…
如何使用Windows 10的bash运行sh脚本?
回答:
通过快速搜索,您的错误似乎与以下问题有关:JENKINS-33708
主要原因可能sh
是Windows不支持该步骤。例如,您可以使用bat
或安装Cygwin
。
但是,在上一个链接中提出了两种解决方案,建议您执行以下步骤:
- 安装git-bash
- 确保Git \ bin文件夹(即
C:\Program Files\Git\bin
:)位于全局搜索路径中,以便Jenkins找到sh.exe - 使nohup可用于Jenkins,在git-bash中执行以下操作(相应地调整路径):
- mklink“ C:\ Program Files \ Git \ \ nohup.exe”“ C:\ Program Files \ git \ usr \ bin \ nohup.exe”
- mklink“ C:\ Program Files \ Git \ \ msys-2.0.dll”“ C:\ Program Files \ git \ usr \ bin \ msys-2.0.dll”
- mklink“ C:\ Program Files \ Git \ \ msys-iconv-2.dll”“ C:\ Program Files \ git \ usr \ bin \ msys-iconv-2.dll”
- mklink“ C:\ Program Files \ Git \ \ msys-intl-8.dll”“ C:\ Program Files \ git \ usr \ bin \ msys-intl-8.dll”
根据您的安装,您可能必须使用以下路径:
- mklink“ C:\ Program Files \ Git \ \ nohup.exe”“ C:\ Program Files \ git \ usr \ bin \ nohup.exe”
- mklink“ C:\ Program Files \ Git \ \ msys-2.0.dll”“ C:\ Program Files \ git \ usr \ bin \ msys-2.0.dll”
- mklink“ C:\ Program Files \ Git \ \ msys-iconv-2.dll”“ C:\ Program Files \ git \ usr \ bin \ msys-iconv-2.dll”
- mklink“ C:\ Program Files \ Git \ \ msys-intl-8.dll”“ C:\ Program Files \ git \ usr \ bin \ msys-intl-8.dll”
以上是 Jenkins管道sh失败,并在Windows上“无法运行程序nohup” 的全部内容, 来源链接: utcz.com/qa/426631.html