How to send variable dynamically from grunt command line to grunt copy task

783 Views Asked by At

I am trying to integrate grunt with Jenkins and having one issue while copying files.

I am trying to pass the file path dynamically from grunt command line so that user can select the path dynamically. Because our version no keeps changing.

So I declared at top of gruntfile.js

var pathValue="";

So I have a task called

grunt.registerTask('deploy', ['copy']);

I am reading the path from commandline as below

grunt --target=\\\\machine1\\versionno\\js\\

var target = grunt.option('target');

My Copy sytax looks as below

copy: {
          main: {
            files: [
              // includes files within path                  
              {expand: true, flatten: true, src: ['dest/**'], dest: **pathValue**, filter: 'isFile'}        
            ]
          }
        },

But somehow the value is not getting set to that variable

Am I missing something? please let me know.

All I want to do is send the value from command line to the destination directory dynamically

Thanks

1

There are 1 best solutions below

0
On

Don't know if that's only something wrong with your example or not but you are never setting the pathValue to your option, try:

pathValue = grunt.option('target');