Jenkins build step fails on ‘npm install

New to Jenkins: I am setting up our build in Jenkins. Setting up a build step to run a nodejs script (a script to take the built app into a native iOS app, with Sencha Touch 2). The nodejs script requires a wrench library.

The Jenkins user appears to be running in a different context. It couldn’t see my node installation or npm installation. As part of the build step, I had to export the path to node and npm. Now that I have done that, the build sees the node and npm commands.

However, one of the commands that I have it calling in the build step is ‘npm install wrench’ and it gives me a permissions error, and tells me to run as Administrator. So I can get it to work.

So I either need to be able to give the Jenkins user admin rights or I need to npm-install the package ahead of time for the user. Does anyone know how to do either of those options.

Answer

I am guessing you are running Jenkins on Mac and you have maybe installed it using the Jenkins Mac installer. I will further guess you installed it with default settings, which means Jenkins is set to run as a launch daemon and running under the account called daemon.

The daemon user is special. It is very secure. The home directory of the daemon user is owned by root and daemon has no write permission there, so it is unable to install anything there.

You can solve your problem by re-running the Jenkins installer but this time click on the Customize button. Check the box that says Start at boot as "jenkins". Uncheck the box that says Start at boot as "daemon".

Leave a Reply

Your email address will not be published. Required fields are marked *