Ant Exec gets Permission Denied

Inside a build we are using a ant exec task in order to run a command (sqlplus).

This works if I run the ant script on my local machine (windows XP) directly (so the antscript itself seems to be ok)

We also can run the command as the "teamcity" user on a Linux box (so its privileges seems to be ok)

By echoing id and env from a little shell script we ensured that the build agent actually runs as "teamcity"

Yet the build fails, giving us:
Execute failed: java.io.IOException: Cannot run program "sqlplus" (in directory "/home/teamcity/work/32c0f9f1f7054f1b/blah"): java.io.IOException: error=13, Permission denied.

When constructing the shell script we noted that we couldn't use the sh shell, it as well gave use a Permission Denied, while using sh was ok when logged on as teamcity directly.

Any hints on what is going on?

2 comments

You might want to add to the path, something like the following

( nant script )

]]>
<variable name="Path" value="%PATH%;$" />
</setenv>
<echo message="the path is now=$"/>


I had the same problem, the environment path is different when running under TC for some reason

0

I ran into this issue too just now, in a couple different ways.

I needed to run a build.xml (the developer's) from the build.xml in our standard location...

First flavor: this fails with  Execute failed: java.io.IOException: Cannot run program "ant" (in directory "C:\src\svn\drw\projects\trading\futures\domino.client.api\scripts"): CreateProcess error=2, The system cannot find the file specified ...

    <target name="package.all" description="build package" >
      <exec executable="ant" dir="../scripts" failonerror="true" />
    </target>


...but this works (contrary to the http://ant.apache.org/manual/CoreTasks/exec.html page's passage for Windows users)...
     ...

      <exec executable="ant.bat" dir="../scripts" failonerror="true" />


     ...

(ant.bat must be in the PATH, of course).


Now for the second flavor...

build.xml calls ../scripts/build.xml, which calls both batch files and "real" executables (as opposed to batch files).  In my local cmd prompt, no problem.  However, in TeamCity it blows up; even the batch file with the explicit ".bat" extension isn't found.  Both the batch file and the executable were in ../scripts.  This is where the pattern in http://ant.apache.org/manual/CoreTasks/exec.html came to the rescue:

Fails inside TeamCity under ant-runner, with   Execute failed: java.io.IOException: Cannot run program "myBatchFile.bat" (in directory "D:\Workspace\CI\DominoClientApi-trunk\scripts"): CreateProcess error=2, The system cannot find the file specified ...

<target name="myTarget" >
      <exec executable="myExecutable" />

      <exec executable="genStuff.bat" />
</target>

...and this works...

<target name="myTarget" >
      <exec executable="cmd" >
        <arg value="/c" />
       <arg value="myExecutable" />
      </exec>

      <exec executable="cmd" >
        <arg value="/c" />
        <arg value="genStuff.bat" />
      </exec>
</target>

0

Please sign in to leave a comment.