Search code examples
ruby-on-rails-4jenkinsrakerake-task

How to run a rake task on jenkins with string parameters?


I have the follow execute shell command:

bundle exec rake ${RAKE_TASK[@]} RAILS_ENV=$ENVIRONMENT

But it doesn't work when I need to run a task with parameters like that:

bundle exec rake {namespace}:{task}['param1 param2']

how I could fix that?


Solution

  • Hi everybody I got the answer:

    $RAKE_TASK may have spaces in it depending on the parameters given to the rake task, which bash/jenkins don't deal with cleanly So, we interpolate the variables into a double-quoted string, then eval the result. This ensures that the spaces don't get messed up.

    bundle install

    echo $ENVIRONMENT

    eval "bundle exec rake $RAKE_TASK RAILS_ENV=$ENVIRONMENT"

    It should be in the jenkins/job/configure page inside of Execute shell command