Ansible don't run gradlew task

Viewed 243

I have one groovy grails project.

I'm beginning with the ansible, and i'm trying run gradle build with him. but when I try it that way, it says there is no such task

ansible-playbook build.yml -u root -v

and inside the server i can run

./gradlew war

this is my task.

- name: Build 
  shell : /tmp/git/test/gradlew war

When i run with task below, Ansible don't show the build and application tasks unlike when I run "./gradle tasks" inside the server

- name: Build 
  shell : /tmp/git/test/gradlew tasks
1 Answers

You need to use chdir argument of shell module:

- name: Build 
  shell : ./gradlew war
  args:
    chdir: /tmp/git/test

As per gradle documentation:

The Wrapper shell script and batch file reside in the root directory of a single or multi-project Gradle build. You will need to reference the correct path to those files in case you want to execute the build from a subproject directory e.g. ../../gradlew tasks.

Note: More info here: documentation.

Related