在Jenkins Windows Slave上运行Shell脚本

时间:2018-11-22 14:17:17

标签: windows shell jenkins scripting cygwin

我已经在Windows10上安装了Jenkins。我正在尝试运行创建文件夹

的shell脚本
#!bin/bash 

DIR1=ShellScript/folder1
if [ -d "$DIR1" ]; then
    echo removing folder 1
    rm -rf "$DIR1"
fi

mkdir "$DIR1"

我已经在Windows上安装了cygwin,并在Jenkins cygwin64 / bin / sh上设置了可执行文件 enter image description here

当我运行时,由于给出错误Permission Denied而导致构建失败。这是日志

    Building in workspace C:\Program Files (x86)\Jenkins\workspace\CreateDir
FSSCM.checkout C:\Users\Admin\Desktop\ShellScript to C:\Program Files (x86)\Jenkins\workspace\CreateDir
FSSCM.check completed in 10 milliseconds
Set build name.
New build name is '#Create Dir2'
$ C:\cygwin64\bin\cygpath -w C:\cygwin64\bin\sh.exe
[CreateDir] $ C:\cygwin64\bin\sh.exe -xe C:\WINDOWS\TEMP\jenkins1863454407248508967.sh
+ ./MyShell.sh
C:\WINDOWS\TEMP\jenkins1863454407248508967.sh: line 2: ./MyShell.sh: Permission denied
Build step 'Execute shell' marked build as failure
Set build name.
New build name is '#Create Dir2'
Finished: FAILURE

请问有人可以提出解决方案吗?  谢谢

0 个答案:

没有答案