17

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

3 Answers 3

31

Add the execution bit to your .sh file

git add --chmod=+x "filename"
Sign up to request clarification or add additional context in comments.

Comments

19

Running bash command.sh worked for me.

1 Comment

I thought it was a direct answer. The way the author is running shell scripts does not work due to permissions. Running the shell scripts as I have outlined will let the author run the she shell script without a permission error.
9

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.