Ant Plugin doesn't seem to set ANT_HOME and PATH accordingly

310 views
Skip to first unread message

Daniel P.

unread,
Nov 21, 2016, 11:04:21 AM11/21/16
to Jenkins Users
Hello everyone,

My (probably relevant) setup:
Solaris 11.3
JDK 1.8.0-102
Jenkins 2.32
Ant Plugin 1.4

I've setup a project which checks out some code and a build.xml for ant. This build.xml contains a target "prepare" that just creates some directories.
I also let Jenkins handle my ant installations via the ant plugin: I selected "automated install" of the newest ant (1.9.7).

So when I first started my build, my code was checked out correctly. Then ant was installed to ${JENKINS_HOME}/tools/hudson.tasks.Ant_AntInstallation/ant (I named that ant installation "ant")
Then my build log says:
16:08:01 [Some_Server] $ /app/jenkins/work/tools/hudson.tasks.Ant_AntInstallation/ant/bin/ant prepare -debug
16:08:01 Buildfile: /app/jenkins/work/workspace/Some_Project/build.xml
16:08:01 
16:08:01 BUILD SUCCESSFUL
16:08:01 Total time: 0 seconds
16:08:01 Finished: SUCCESS

I have a user "ci" that jenkins is running as, the JENKINS_HOME folder has been appropriately given permissions and ownership.
The ant installation looks fine. The "ci" user has a default PATH.

When I add the ant installation folder
/app/jenkins/work/tools/hudson.tasks.Ant_AntInstallation/ant/bin
to the PATH as another user than the "ci" user, it correctly fails because that user doesn't have the correct permissions to create the directories.
So I guess the problem is that ant looks for something in the ant folder, which isn't in the PATH.

My understanding is that I should let Jenkins manage my ant installations and select the appropriate ant installation for my project.
But when I build that project and output the environment and shell variables (env, set) during build, neither ANT_HOME is set nor the PATH is accordingly set to incorporate the ant installation used for the build.

Is this normal? Doesn't the build use ANT_HOME to select the ant installation it uses?

Regards,
Daniel Poggenpohl

Daniel P.

unread,
Nov 22, 2016, 7:01:56 AM11/22/16
to Jenkins Users
Hello,

I've since found out that ANT_HOME is only set directly before invoking ant, which explains why it is not displayed in the environment. I've further dug down and found that (of course) the bug is because I'm using Solaris...
The ant wrapper shell script parses the arguments given. There is a line where remaining arguments are put inside of quotes and some escaped stuff is removed using sed.
The problem is that the Solaris 11.3 version of sed doesn't do this right and removes all characters. So when I say
ant someTarget
, the script transforms this to
ant ""
instead of
ant "someTarget".
This also explains why no options for the main java ant script work through the shell wrapper and why invoking only ant works (no arguments means building the default).

I'll file a bug at ant...

Regards,
Daniel Poggenpohl
Reply all
Reply to author
Forward
0 new messages