Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins No such file or directory error. But the file exists

I have a problem with running bash script as a job in Jenkins (Execute shell step). Basically I narrowed my script to be one line now to test why Jenkins fails to run it. Here it is:

waxsim

So it is just one line. That should give me this output when ran without parameters:

No app-path was specified!
usage: waxsim [options] app-path
example: waxsim -s 2.2 /path/to/app.app
Available options are:
    -s sdk  Version number of sdk to use (-s 3.1)
    -f family   Device to use (-f ipad)
    -e VAR=value    Environment variable to set (-e CFFIXED_HOME=/tmp/iphonehome)
    -a  Available SDKs
    -v path Output video recording at path
    -h  Prints out this wonderful documentation!

Jenkins runs as a jenkins user. When the job is ran it fails with:

+ waxsim
/var/folders/gx/t63prwt53w7gr2jjt9k66q9800009c/T/hudson4478539334800834890.sh: 
line 3: waxsim: No such file or directory
Build step 'Execute shell' marked build as failure

When I execute waxsim manually, logged in as a jenkins user, everything works fine. It works for every user on the machine. It does not work only when executed in Jenkins job. Anyone knows what may be the issue?

I tried specifying the full path to waxsim, which is: /usr/bin/waxsim but it makes no difference.

Thanks!

like image 671
Rafa de King Avatar asked Jun 17 '13 09:06

Rafa de King


2 Answers

The reason why it works when ran in the Terminal and it doesn't when ran by Jenkins turned out to be trivial.

In the Terminal I run bash, and Jenkins is using shell. Thus, adding exporting the PATH to the Jenkins' execute shell script solved the issue.

like image 68
Rafa de King Avatar answered Nov 09 '22 19:11

Rafa de King


Simply adding #!/bin/bash to the top of your shell execution should give you the desired results.

like image 1
Ryan Avatar answered Nov 09 '22 19:11

Ryan