0

Actually I already have application with java as a backend and backbonejs app as frontend. Both are completely separate. Now I have introduced grunt tasks in my front end which I need to be executed before packaging war file. So that packaged war files have files generated by grunt task.

Locally I can execute grunt tasks from maven.

But for deployment we have been using cloudbees. I tried searching on internet but I haven't got any solution. Though I have gone through a question "How do I get a grunt task working with a Cloudbees Jenkins build" and also through documentation but still I am clueless.

My guess is I need to run grunt tasks post build as a shell script.

So how to setup node.js environment for existing maven project on cloudbees?

Community
  • 1
  • 1
Bharat Patil
  • 1,398
  • 1
  • 11
  • 28

1 Answers1

0

This is what I do to run grunt - I have it located in a script bin/build-ci

Call the script below from a shell build step in Jenkins

If you are running grunt commands, then they need to be run in the same build step as the environment is manipulated (and these changes are not carried from one step to the next).

# This script is normally in a ./bin/ subdirectory, so we grab BASEDIR as the parent
BASEDIR=`dirname $0`/..

curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
NODE_VERSION=0.10.18 . ./use-node

# Make sure grunt and grunt-cli are in your package.json manifest
npm install

export PATH=$BASEDIR/node_modules/.bin:$PATH

grunt
Ben Walding
  • 4,006
  • 2
  • 30
  • 28
  • Yes currently I am trying following shell script in pre build: node_version=0.10.21 `if [ ! -e nodejs-plugin-$node_version.zip ] then wget https://s3.amazonaws.com/clickstacks/admin/nodejs-plugin-$node_version.zip unzip nodejs-plugin-$node_version.zip tar xf node.tar.gz mv node-v* node_lib fi export PATH=$PATH:$WORKSPACE/node_lib/bin node -v` – Bharat Patil Nov 01 '13 at 05:16
  • will it break jenkin build because I am getting an error while parsing POM file. – Bharat Patil Nov 01 '13 at 05:19