Ionic command doesn't works for jenkins job

176 views
Skip to first unread message

Francesco Sisca

unread,
Jan 8, 2018, 11:25:00 AM1/8/18
to Jenkins Users
Hello everyone, i'm in trouble about some jenkins stuff.

I have a hybrid application, and i need to setup automatic build for that. i follow those steps to build the app.

npm i
ionic cordova platform add android --no-interactive
ionic cordova build android --prod --no-interactive

and that's works fine. But when i put this commands into a build.sh file, and put this file into Jenkins "shell command", when i run "build" into jenkins, i get an error "ionic: command not found".

I'm working on MacOS, and Jenkins have a separate User. Of Course, from CLI, all works fine.

Victor Martinez

unread,
Jan 8, 2018, 11:36:51 AM1/8/18
to Jenkins Users
It sounds a kind of environmental issue with the PATH env variable. You can confirm how that particular PATH env variable looks like in your local and also within Jenkins, then you can set it accordingly,.

Cheers

Francesco Sisca

unread,
Jan 8, 2018, 11:49:09 AM1/8/18
to Jenkins Users

Thanks for the answer!

this is  ENV PATH for the owner (masdev).



Mac-mini-di-masdev:mobilehub-reference-application masdev$ echo $PATH

/Users/masdev/.rvm/gems/ruby-2.4.2/bin:/Users/masdev/.rvm/gems/ruby-2.4.2@global/bin:/Users/masdev/.rvm/rubies/ruby-2.4.2/bin:~/.npm-global/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/masdev/Library/Android/sdk/tools:/Users/masdev/Library/Android/sdk/platform-tools:/Users/masdev/Downloads/apache-maven-3.5.2/bin:/Users/masdev/.rvm/bin


while ENV PATH on the jenkins user (Jenkins) is this  



how i fix this?

Victor Martinez

unread,
Jan 8, 2018, 2:11:57 PM1/8/18
to Jenkins Users
It looks like this is not an issue within Jenkins itself but the agent configuration. I'm afraid you need to install all the specific requirements in the agent and I'm not sure if those env variables refers to the same machine or two different ones.
Therefore, whoever owns that particular agent might help you to set it up accordingly, just in case they use any kind of configuration management tool. In case you need to bypass the above, you can append to the PATH env variable with the path to that particular ionic binary before running any shell stuff


Something like :

PATH=$PATH:<ionic-absolute-path>
<then the rest of ionic commands you run>

My two cents

Francesco Sisca

unread,
Jan 8, 2018, 2:28:05 PM1/8/18
to Jenkins Users
ok thanks for the advice
Reply all
Reply to author
Forward
0 new messages