从 Jenkins 启动 .bat 不起作用 [英] Launch a .bat from Jenkins does not work

查看:33
本文介绍了从 Jenkins 启动 .bat 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 .bat 文件:

This is the .bat file :

start cmd.exe /k "C:\Users\etudes.ext46\AppData\Local\Android\sdk1\tools\emulator.exe -avd ff &"
ping 127.0.0.1 -n 60 > nul
start cmd.exe /k "adb shell input keyevent 82"
start cmd.exe /k "node "C:\Program Files\Appium\node_modules\appium\bin\appium.js" -a 127.0.0.1 -p 4723 &"
ping 127.0.0.1 -n 30 > nul
C:\Users\etudes.ext46\Downloads\NUnit-2.6.4\NUnit-2.6.4\bin\nunit-console.exe C:\Users\etudes.ext46\Downloads\NUnit-2.6.4\NUnit-2.6.4\bin\apk\UnitTestProject1.dll
start cmd.exe /k "taskkill /F /IM emulator-x86.exe"
start cmd.exe /k "taskkill /F /IM node.exe"
start cmd.exe /k "taskkill /F /IM cmd.exe"

当我手动运行它时,它运行良好(模拟 Android 设备并使用 Appium 和 Nunit 测试).

When i run it manually, it works pretty well (emulate an android device an use Appium with Nunit tests).

但是当我尝试从 Jenkins 启动 完全 相同的 .bat 时,它不起作用

But when I try to launch the exact same .bat from Jenkins it doesn't work

Errors and Failures:
1) TearDown Error : AppiumSample.ASSI2.AssistanceV2
   SetUp : System.InvalidOperationException : A new session could not be created. (Original error: Could not find a connected Android device.) (33)
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.

完整的日志在这里:http://img.prntscr.com/img?url=http://i.imgur.com/KsrEJiT.png

我怎样才能让这个 .bat 与 Jenkins 一起工作?

How can I make this .bat work with Jenkins?

推荐答案

解决方案是在启动模拟器时添加选项-no-window

The solution was to add the option -no-window when launching the emulator

start cmd.exe /k "C:\path\emulator.exe -avd ff -no-window &"

代替

start cmd.exe /k "C:\path\emulator.exe -avd ff &"

这篇关于从 Jenkins 启动 .bat 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆