Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build failure while running shell command from Jenkins

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
like image 931
Pawankumar Dubey Avatar asked Nov 11 '14 06:11

Pawankumar Dubey


People also ask

How do I fix Jenkins build failure?

In Jenkins, in the pipeline where the failure occurred, in the navigation pane, click Rebuild. In the Rebuild page, select the ReRun check box , and click Rebuild.

How fail Jenkins job if shell script fails?

By default Jenkins take /bin/sh -xe and this means -x will print each and every command. And the other option -e , which causes shell to stop running a script immediately when any command exits with non-zero (when any command fails) exit code. So by adding the #!/bin/sh will allow you to execute with no option.

How does Jenkins know when a build fails?

This plugin analyzes the causes of failed builds and presents the causes on the build page. It does this by using a knowledge base of build failure causes that is built up from scratch. Saving statistics about failure causes is also possible.


1 Answers

Add the execution bit to your .sh file

git add --chmod=+x "filename"
like image 156
Nilamber Singh Avatar answered Oct 04 '22 01:10

Nilamber Singh