jenkins执行shell命令提示找不到命令解决办法

用jenkins执行shell脚本,执行一条命令:

#唤醒休眠手机
adb shell input keyevent 2

提示:

[adb] $ /bin/sh -xe /Users/xxxxx/tools/apache-tomcat-8.5.30/temp/jenkins8525959692743554347.sh
+ adb shell input keyevent 26
/Users/xxxxx/tools/apache-tomcat-8.5.30/temp/jenkins8525959692743554347.sh: line 4: adb: command not found
Build step '执行 shell' marked build as failure
Finished: FAILURE


原因:在jenkins shell中执行没有加载/etc/profile .bash_profile中的环境变量
需要在shell 命令前面加一条申明:
#!/bin/bash -il
#!/bin/bash -il

#唤醒休眠手机
adb shell input keyevent 26

这样就能正常执行命令了。

[adb] $ /bin/bash -il /Users/xxxx/tools/apache-tomcat-8.5.30/temp/jenkins3562542453282352376.sh
bash: no job control in this shell
Restored session: 2018年 5月 4日 星期五 15时12分55秒 CST
Saving session...
...saving history...
...completed.
Finished: SUCCESS




猜你喜欢

转载自www.cnblogs.com/testway/p/8990867.html