如何从Jenkins运行批处理文件

时间:2016-10-28 09:20:16

标签: batch-file jenkins cmd

我正在尝试从Jenkins运行批处理文件,但我无法运行它。 在预构建步骤中,我已经输入了我想要执行的文件,但是我得到了如下所示的堆栈跟踪。 Jenkins无法识别cmd命令。

我该如何解决这个问题?

Started by user Jenkins
[EnvInject] - Loading node environment variables.
Building in workspace /srv/jenkins/workspace/gaa-integratietest-daily
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url ssh://git@poosgitl01.ont.belastingdienst.nl:7999/gaa/gaa_test_milieu.git # timeout=10
Fetching upstream changes from ssh://git@poosgitl01.ont.belastingdienst.nl:7999/gaa/gaa_test_milieu.git
 > git --version # timeout=10
 > git -c core.askpass=true fetch --tags --progress ssh://git@poosgitl01.ont.belastingdienst.nl:7999/gaa/gaa_test_milieu.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse origin/develop^{commit} # timeout=10
Checking out Revision 337d5b94e05f2c915e05de2c2535d5af180d4326 (origin/develop)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 337d5b94e05f2c915e05de2c2535d5af180d4326
 > git rev-list 337d5b94e05f2c915e05de2c2535d5af180d4326 # timeout=10
[gaa-integratietest-daily] $ /bin/sh -xe /tmp/hudson1965771098535657790.sh
+ cmd /c qclient.bat
/tmp/hudson1965771098535657790.sh: line 2: cmd: command not found
Build step 'Execute shell' marked build as failure
[gaa-integratietest-daily] $ /usr/share/maven/bin/mvn -f pom.xml -gs /srv/maven/settings.xml clean deploy -fae
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project  (/srv/jenkins/workspace/gaa-integratietest-daily/pom.xml) has 1 error
[ERROR]     Non-readable POM /srv/jenkins/workspace/gaa-integratietest-daily/pom.xml: /srv/jenkins/workspace/gaa-integratietest-daily/pom.xml (No such file or directory)
[ERROR] 

2 个答案:

答案 0 :(得分:0)

您正在尝试在LINUX计算机上运行CMD。要么将正在运行的从站更改为Windows计算机,要么将Batch脚本迁移到shell脚本。

祝你好运!

答案 1 :(得分:0)

您的Linux Jenkins从站不支持cmd 。为了解决这个问题,你有几个选择(从好到坏):

  1. 将一个Windows奴隶添加到Jenkins并从那里运行cmd。
  2. 将批处理文件移植到bash或类似文件,然后从Linux Jenkins slave运行它。
  3. 在Linux Jenkins slave中添加某种DOS模拟器(Wine,DOSBox,DOSemu)。
  4. 我的建议:如果您了解Linux& Bash或你无法控制Jenkins 选择2 。否则请转到选项1.避免选项3.