5
votes

I'm trying to get a Jenkins build up and running on Cloudbees. I've successfully gotten NodeJs installed and my source pulled from my BitBucket repository. I am trying to run my grunt task to minify and concatenate my JS and CSS files before deploying. However, I am not able to run the grunt program, even though it is successfully installed. Below is my build script:

curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
NODE_VERSION=0.8.0 \
 source ./use-node
npm install
npm install grunt
grunt

I've tried installing grunt with and without the -g option without success. Here is the console output for the grunt portion of my build:

+ npm install grunt
...
npm http GET https://registry.npmjs.org/grunt
npm http 200 https://registry.npmjs.org/grunt
...
[email protected] node_modules/grunt
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected])
+ grunt
/tmp/hudson3382014549646667419.sh: line 8: grunt: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Any ideas on how to get this working? Is this even possible in Cloudbees?

2
I think nom install -g grunt may work - but let me reproduce and confirm below....Michael Neale

2 Answers

5
votes

Grunt is now broken up, annoyingly, into a separate cli module. Also, annoyingly, that cli module does not include grunt itself.

To make this work:

curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
NODE_VERSION=0.8.0 \
 source ./use-node
npm install
npm install grunt
npm install grunt-cli
export PATH=$PATH:node_modules/grunt-cli/bin/
grunt

If the folk making this change how it works to be sensible, then it may change in future.

Docs here: http://gruntjs.com/getting-started

0
votes

you can setup everything from a jenkins job, no ssh/command line required:

Install Jenkins Plugins

  • Git Plugin - for git
  • Git Client Plugin - for git
  • Git Parameter Plugin - for git tags
  • GitHub API Plugin - for github
  • NodeJS Plugin - integration for common javascript tools NodeJS & npm

Git / Ant / Maven / NodeJS Installations

  • Goto SERVER/jenkins/configure
  • Git -> Git installations -> Add Git -> JGit
  • Git plugin -> Global Config user.name Value = "Anthony Mckale", Global Config user.email Value = "[email protected]"
  • NodeJS- > NodeJS installations -> Add NodeJS -> Name = "NodeJS 0.11.10", tick "Install automatically", select "Install from nodejs.org", add "grunt-cli" to globally installed packages

TADA

and hopefully git/nodejs and grunt will be available to you

see the plugin wiki for more details how to add the grunt/node tasks to the jenkins job -> https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

it's really easy :)

no ssh loggin required just jenkins admin rights