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
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.
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.
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.
Add the execution bit to your .sh file
git add --chmod=+x "filename"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With