jenkins執行shell命令提示找不到命令解決辦法

用jenkins執行shell腳本,執行一條命令:shell

#喚醒休眠手機 adb shell input keyevent 2

 

提示:apache

[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

 

這樣就能正常執行命令了。tomcat

 

[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
相關文章
相關標籤/搜索