0

I try to run this gradle task (via gradlew)

which uses cucmber jvm

task callCL (type: Exec) {
    commandLine './build/distributions/WebLargeTests/bin/WebLargeTests  -f html:build/reports/cucumber/ -f json:build/reports/cucumber/report.json --glue com.mayApp.testing.cucumber src/main/resources/features --tags ~@ignore -f rerun'
}

and get this error

:callCL FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':callCL'.
> A problem occurred starting process 'command './build/distributions/WebLargeTests/bin/WebLargeTests  -f html:build/reports/cucumber/ -f json:build/reports/cucumber/report.json --glue com.myApp.testing.cucumber src/main/resources/features --tags ~@ignore -f rerun''

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.448 secs
error=2, No such file or directory
3:48:00 PM: External task execution finished 'callCL'.

when I run the same line from the same path in cmd:

/build/distributions/WebLargeTests/bin/WebLargeTests  -f html:build/reports/cucumber/ -f json:build/reports/cucumber/report.json --glue com.myApp.testing.cucumber src/main/resources/features --tags ~@ignore -f rerun
Starting ChromeDriver (v2.9.248307) on port 12095
Starting ChromeDriver (v2.9.248307) on port 34150
Starting ChromeDriver (v2.9.248307) on port 29495
Starting ChromeDriver (v2.9.248307) on port 8792
Starting ChromeDriver (v2.9.248307) on port 23779
Starting ChromeDriver (v2.9.248307) on port 3553

update1:

this cmd works in a shell console:

./build/distributions/WebLargeTests/bin/WebLargeTests -f html:build/reports/cucumber/ -f json:build/reports/cucumber/report.json --glue com.waze.testing.cucumber src/main/resources/features --tags @only -f rerun

but not in the build.gradle

task callCL (type: Exec) {
    commandLine 'bash', './build/distributions/WebLargeTests/bin/WebLargeTests', '-f',
            'html:build/reports/cucumber/', '-f', 'json:build/reports/cucumber/report.json', '--glue',
            'com.waze.testing.cucumber', 'src/main/resources/features', '--tags', '@ignore', '-f', 'rerun'

    //store the output instead of printing to the console:
    standardOutput = new ByteArrayOutputStream()

    //extension method stopTomcat.output() can be used to obtain the output:
    ext.output = {
        return standardOutput.toString()
    }
}

btw

I want the cmd to be:

./build/distributions/WebLargeTests/bin/WebLargeTests -f html:build/reports/cucumber/ -f json:build/reports/cucumber/report.json --glue com.waze.testing.cucumber src/main/resources/features --tags @only -f rerun --out rerun.txt

but not in the build.gradle

task callCL (type: Exec) {
    commandLine 'bash', './build/distributions/WebLargeTests/bin/WebLargeTests', '-f',
            'html:build/reports/cucumber/', '-f', 'json:build/reports/cucumber/report.json', '--glue',
            'com.waze.testing.cucumber', 'src/main/resources/features', '--tags', '@ignore', '-f', 'rerun', '--out', 'rerun.txt'

    //store the output instead of printing to the console:
    standardOutput = new ByteArrayOutputStream()

    //extension method stopTomcat.output() can be used to obtain the output:
    ext.output = {
        return standardOutput.toString()
    }
}

but this doesn't work (shell concole nore build.gradle)

Elad Benda2
  • 13,852
  • 29
  • 82
  • 157
  • You've `commandLine` wrong defined for sure. Should be e.g.: `commandLine 'bash','script.sh'` – Opal Jul 23 '14 at 13:01
  • added `commandLine 'bash','` and got: Process 'command 'bash'' finished with non-zero exit value 127 – Elad Benda2 Jul 23 '14 at 13:08
  • This is not a problem of `bash` in the beginning of command, but all command args should be esacped with `'` separately. – Opal Jul 23 '14 at 13:10
  • so I ran: ` task callCL (type: Exec) { commandLine 'bash', './build/distributions/WebLargeTests/bin/WebLargeTests', '-f', 'html:build/reports/cucumber/', '-f', 'json:build/reports/cucumber/report.json', '--glue', 'com.waze.testing.cucumber', 'src/main/resources/features', '--tags', '@ignore', '--out', 'rerun.txt' }` and got: `:callCL FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':callCL'. > Process 'command 'bash'' finished with non-zero exit value 1 – Elad Benda2 Jul 23 '14 at 13:17
  • Add output handling to see errors: http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.Exec.html – Opal Jul 23 '14 at 13:34
  • tried, but saw no additional info:* What went wrong: Execution failed for task ':callCL'. > Process 'command 'bash'' finished with non-zero exit value 1 * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 3.344 secs Process 'command 'bash'' finished with non-zero exit value 1 5:03:23 PM: External task execution finished 'callCL'. – Elad Benda2 Jul 23 '14 at 14:03
  • Is this command working when run just from command line? – Opal Jul 23 '14 at 14:08
  • yes. That's why i'm lost – Elad Benda2 Jul 23 '14 at 14:38
  • Ok. Paste here the full argument You pass to `commandLine` in exec task. – Opal Jul 23 '14 at 14:50
  • Still not sure if `bash` is needed. – Opal Jul 23 '14 at 14:59
  • http://stackoverflow.com/questions/24895370/how-can-i-run-new-gradle-task -- you mean this won't help? – AKS Jul 23 '14 at 16:03

1 Answers1

0

See if this works!

Note: I'm using /build/... path instead of using a dot first then slash: ./build/...

task callCL(type: Exec) {

        executable "bash"
        args "-c", "bash /build/distributions/WebLargeTests/bin/WebLargeTests -f html:build/reports/cucumber/ -f json:build/reports/cucumber/report.json --glue com.waze.testing.cucumber src/main/resources/features --tags @only -f rerun"


        // If you want the store the output to a file, you can also try the following
        //args "-c", "bash /build/distributions/WebLargeTests/bin/WebLargeTests -f html:build/reports/cucumber/ -f json:build/reports/cucumber/report.json --glue com.waze.testing.cucumber src/main/resources/features --tags @only -f rerun 1>/some/path/somefile.log 2>&1"

        //store the output instead of printing to the console:
        standardOutput = new ByteArrayOutputStream()

        //extension method stopTomcat.output() can be used to obtain the output:
        ext.output = {
           return standardOutput.toString()
        }
}
AKS
  • 16,482
  • 43
  • 166
  • 258