【发布时间】:2020-05-08 23:04:35
【问题描述】:
是否可以使用 Cygwin 在 jenkins 中运行 sh 步骤?我尝试过的方法不起作用。
为了让 sh 步骤与 cygwin 一起工作,我使用了配置屏幕 http://<jenkins>:8080/configure 并将 Shell Executable 设置为运行 C:\\cygwin64\\bin\\bash.exe 但是在运行测试管道时
node {
stage('1'){
bat "dir C:\\cygwin64\\bin\\bash.exe"
sh 'ls ..'
}
}
这就是结果。
Running on Jenkins in J:\workspace\try_shellx
[Pipeline] {
[Pipeline] stage
[Pipeline] { (1)
[Pipeline] bat
J:\workspace\try_shellx>dir C:\cygwin64\bin\bash.exe
Volume in drive C has no label.
Volume Serial Number is 9CDC-D180
Directory of C:\cygwin64\bin
01/27/2017 01:13 PM 739,859 bash.exe
1 File(s) 739,859 bytes
0 Dir(s) 294,634,586,112 bytes free
[Pipeline] sh
sh: C:\cygwin64\bin\bash.exe: command not found
[Pipeline] }
[Pipeline] // stage
因此,sh "ls .." 无法执行,因为找不到 bash,但通过 bat 步骤找到了 dir C:\\cygwin64\\bin\\bash.exe
任何帮助表示赞赏
【问题讨论】:
标签: bash jenkins jenkins-pipeline cygwin windows-subsystem-for-linux