Build failure while running shell command from Jenkins

 ̄綄美尐妖づ 提交于 2020-04-12 08:20:54

问题


I am invoking shell script to build my source code via jenkins 'Invoke Shell' option. My command goes like:

export PATH=$PATH:/usr/bin/repo
cd /home/administrator/administrator/repo_sync
whoami
source ./build/envsetup.sh 
choosecombo release project_int_factory eng

Resulting to which i am getting below error. I have given full permission to folder. Source code location is /home/administrator/administrator/repo_sync. I have tried with sudo chmod +x administrator & sudo chmod 777 administrator but nothing helps. plus whoami return jenkins

Building in workspace /home/administrator/administrator/repo_sync
    [repo_sync] $ /bin/sh -xe /tmp/hudson1461193343405073934.sh
    + export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:/usr/lib/jvm/java-6-openjdk-amd64/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/var/lib/jenkins/lib:/usr/lib/jvm/java-6-openjdk-amd64/bin:/home/administrator/pawan/adt-bundle-linux-x86_64-20140702/sdk/tools:/home/administrator/pawan/adt-bundle-linux-x86_64-20140702/sdk/platform-tools:/usr/bin/repo
    + cd /home/administrator/administrator/repo_sync
    + whoami
    jenkins
    + source ./build/envsetup.sh
    /tmp/hudson1461193343405073934.sh: 5: /tmp/hudson1461193343405073934.sh: source: Permission denied
    Build step 'Execute shell' marked build as failure
    Finished: FAILURE

回答1:


Jenkins scripts (and "Execute Shell" build step is a script) are executed with the user that Jenkins runs with. By default, Jenkins runs as jenkins user

Your script is executed as "jenkins" user, as is evident from:
+ whoami
jenkins

You should be executing your chmod commands for jenkins user, not administrator.




回答2:


Add the execution bit to your .sh file

git add --chmod=+x "filename"



回答3:


Running bash command.sh worked for me.



来源:https://stackoverflow.com/questions/26858599/build-failure-while-running-shell-command-from-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!