Gradle exec finds problem in executing a shell script(containing sqlplus command)

I have a shell script which connects to database using sqlplus command. When I type sqlplus in command prompt, user name is propmted confirming sqlplus is installed and is available.

when I try to execute the same shell script using gradle exec, the shell script exits with error sqlplus: command not found

In order to help, we’ll need more information. Which OS? Is ‘sqlplus’ an executable or batch script? Are you running Gradle under the same OS user as ‘sqlplus’ on the command line? Can you verify that putting ‘println(System.getenv(“PATH”))’ into a build script prints the path to ‘sqlplus’?

OS is windows. I am running gradle from cygwin installed in windows. sqlplus is an exe file and it is in path.

I use gradle’s project.exec with

executable = C:/cygwin/bin/sh.exe

args = sample.sh

where sample.sh script tries to connect to db using command sqlplus.

Interestingly if I use ant.exec inside gradle, the script it works fine. The problem is only with gradle’s project.exec where the script raises error sqlplus command not found

Question: Are you running Gradle under the same OS user as sqlplus on the command line?

Answer: yes

Question: Can you verify that putting println(System.getenv(“PATH”)) into a build script prints the path to sqlplus? Anwer: verified and yes the path to sqlplus is available.

Sorry, I can’t tell from here what’s going wrong. Maybe you can find something in the logs (’–info’, ‘–debug’).