1

My current task is to make a Jenkins job which will download a git repo, will gulp build a project and finally will sync data to an S3 bucket. My trouble is with gulp build command which root can't find.

I read that post about installing nvm globally and after using:

wget -qO- https://raw.githubusercontent.com/xtuple/nvm/master/install.sh | sudo bash

was able to install nvm to /usr/local/nvm.

Inside the project directory (/var/lib/jenkins/project) I run:

sudo /usr/local/bin/npm install

and all modules go to node_modules dir inside project dir.

Then I do:

sudo gulp build --env=production
sudo: gulp: command not found

It looks like root can't find gulp. Inside node_modules/gulp/bin there is a gulp.js file but I have no idea how to use it.

So how can I make gulp build work for root? Previously I installed and build the project with a minor effort using a regular user and I know the project is ok, the problem manifested after switching to root.

My working env is Amazon Linux with node.js version 4.4.7. These are my first steps with nvm, gulp and node.js as a whole, so please, don't be too harsh if I'm doing something obviously stupid.

Community
  • 1
  • 1
ERIK_SON
  • 379
  • 5
  • 16

2 Answers2

2

I think you have to install gulp-cli as well:

sudo /usr/local/bin/npm install -g gulp-cli

Gulp global command is different with local gulp you found at node_modules/gulp/bin

egig
  • 4,370
  • 5
  • 29
  • 50
  • I did that, and gulp was installed in /usr/local/nvm/v4.4.7 but when I run `sudo /usr/local/nvm/v4.4.7/bin/gulp build --env=production` it says: `/usr/bin/env: node: No such file or directory` – ERIK_SON Aug 08 '16 at 11:16
0

Jenkins doesn't honor your environment variables, do the following to use gulp:

cd "to dir containing node_modules"
sudo nodejs ./node_modules/gulp/bin/gulp.js sometask
adnan kamili
  • 8,967
  • 7
  • 65
  • 125