Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-7442

Ant build steps with properties including variables are broken

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • ant-plugin
    • None
    • Hudson 1.376 on Windows 2003 Server with Tomcat 6.

      If Ant build steps take properties with an %, the next char is enclosed in quotes in a 'fancy' way:
      $ cmd.exe /C '"C:\ant\apache-ant-1.7.1\bin\ant.bat "-Dhudsonhome=%"H"UDSON_HOME%" && exit %%ERRORLEVEL%%"'
      The property should be "-Dhudsonhome=%HUDSON_HOME%"

      This worked with Hudson 1.365

          [JENKINS-7442] Ant build steps with properties including variables are broken

          skorsky added a comment - - edited

          Sorry, but this is yet not fixed.

          The command line for Ant on Windows expands "vBTAG=$BUILD_TAG"
          to "-D""vBTAG=jenkins-Test Jenkins7442-6""". It should be "-DvBTAG=jenkins-Test Jenkins7442-6".

          The windows cmd interprets the first as two arguments '-DvBTAG=jenkins-Test' and 'Jenkins7442-6"'. But this has to be one argument '-DvBTAG=jenkins-Test Jenkins7442-6'.

          This happens regardless of using "vBTAG=$BUILD_TAG" or "vBTAG=%BUILD_TAG%".

          Tested with Jenkins 1.403

          skorsky added a comment - - edited Sorry, but this is yet not fixed. The command line for Ant on Windows expands "vBTAG=$BUILD_TAG" to "-D""vBTAG=jenkins-Test Jenkins7442-6""". It should be "-DvBTAG=jenkins-Test Jenkins7442-6". The windows cmd interprets the first as two arguments '-DvBTAG=jenkins-Test' and 'Jenkins7442-6"'. But this has to be one argument '-DvBTAG=jenkins-Test Jenkins7442-6'. This happens regardless of using "vBTAG=$BUILD_TAG" or "vBTAG=%BUILD_TAG%". Tested with Jenkins 1.403

          Alan Harder added a comment -

          sorry, not sure where your quotes are literal or not.
          in the ant properties box did you enter:
          vBTAG=$BUILD_TAG
          or
          "vBTAG=$BUILD_TAG"
          ?

          Can you try the former and paste the line shown in the build console?

          Alan Harder added a comment - sorry, not sure where your quotes are literal or not. in the ant properties box did you enter: vBTAG=$BUILD_TAG or "vBTAG=$BUILD_TAG" ? Can you try the former and paste the line shown in the build console?

          skorsky added a comment -

          I used "vBTAG=$BUILD_TAG"

          When I use vBTAG=$BUILD_TAG, it works fine. The command line is
          [workspace] $ cmd.exe /C '"D:\Tools\apache-ant-1.8.2\bin\ant.bat -DvJURL=http://localhost:8080/jenkins/job/Test%20Jenkins7442/ "-DvBTAG=jenkins-Test Jenkins7442-4" -DvNN="" -DvBURL=http://localhost:8080/jenkins/job/Test%20Jenkins7442/4/ -DvBID=2011-03-22_17-52-13 -DvNLAB=master -DvHH=D:\HudsonHome -DvJAVH=D:\Tools\jdk1.6.0_24$ "-DvJN=Test Jenkins7442" -DvBNUM=4 -DvHURL=http://localhost:8080/jenkins/ "-DvWS=D:\HudsonHome\jobs\Test Jenkins7442\workspace" -DvJH=D:\HudsonHome -DvEXEC=1 && exit %%ERRORLEVEL%%"'

          skorsky added a comment - I used "vBTAG=$BUILD_TAG" When I use vBTAG=$BUILD_TAG, it works fine. The command line is [workspace] $ cmd.exe /C '"D:\Tools\apache-ant-1.8.2\bin\ant.bat -DvJURL= http://localhost:8080/jenkins/job/Test%20Jenkins7442/ "-DvBTAG=jenkins-Test Jenkins7442-4" -DvNN="" -DvBURL= http://localhost:8080/jenkins/job/Test%20Jenkins7442/4/ -DvBID=2011-03-22_17-52-13 -DvNLAB=master -DvHH=D:\HudsonHome -DvJAVH=D:\Tools\jdk1.6.0_24$ "-DvJN=Test Jenkins7442" -DvBNUM=4 -DvHURL= http://localhost:8080/jenkins/ "-DvWS=D:\HudsonHome\jobs\Test Jenkins7442\workspace" -DvJH=D:\HudsonHome -DvEXEC=1 && exit %%ERRORLEVEL%%"'

          Alan Harder added a comment -

          Ok, reclosing.
          The help text already mentions issues with quotes, I believe.

          Alan Harder added a comment - Ok, reclosing. The help text already mentions issues with quotes, I believe.

          dogfood added a comment -

          Integrated in jenkins_main_trunk #620
          [FIXED JENKINS-7442] Change ArgumentListBuilder.toWindowsCommand() to not escape %VAR%

          alanharder : c4590529f731ba30b5deb0961d73f76e35ab70ff
          Files :

          • changelog.html
          • war/src/main/webapp/help/ant/ant-properties.html
          • test/src/test/java/hudson/tasks/AntTest.java
          • core/src/test/java/hudson/util/ArgumentListBuilderTest.java
          • core/src/main/java/hudson/util/ArgumentListBuilder.java

          dogfood added a comment - Integrated in jenkins_main_trunk #620 [FIXED JENKINS-7442] Change ArgumentListBuilder.toWindowsCommand() to not escape %VAR% alanharder : c4590529f731ba30b5deb0961d73f76e35ab70ff Files : changelog.html war/src/main/webapp/help/ant/ant-properties.html test/src/test/java/hudson/tasks/AntTest.java core/src/test/java/hudson/util/ArgumentListBuilderTest.java core/src/main/java/hudson/util/ArgumentListBuilder.java

          Code changed in jenkins
          User: alanharder
          Path:
          core/src/main/java/hudson/tasks/Ant.java
          test/src/test/java/hudson/tasks/AntTest.java
          http://jenkins-ci.org/commit/ant-plugin/8971063149d1242188f25455a955cce4990e9eab
          Log:
          [FIXED JENKINS-7442] Fix expansion of EnvVars in ant properties.
          Ant build step had quite a mix: buildFile and antOpts expanded against
          env, properties against buildVariables, and targets against both.
          Now merging buildVariables into env and applying to all.

          Originally-Committed-As: 5f1fef602c6a5672df6edcc84c73c47ff70bb71b

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: alanharder Path: core/src/main/java/hudson/tasks/Ant.java test/src/test/java/hudson/tasks/AntTest.java http://jenkins-ci.org/commit/ant-plugin/8971063149d1242188f25455a955cce4990e9eab Log: [FIXED JENKINS-7442] Fix expansion of EnvVars in ant properties. Ant build step had quite a mix: buildFile and antOpts expanded against env, properties against buildVariables, and targets against both. Now merging buildVariables into env and applying to all. Originally-Committed-As: 5f1fef602c6a5672df6edcc84c73c47ff70bb71b

          Code changed in jenkins
          User: alanharder
          Path:
          test/src/test/java/hudson/tasks/AntTest.java
          war/src/main/webapp/help/ant/ant-properties.html
          http://jenkins-ci.org/commit/ant-plugin/f84ca39415be5312f9170de5a7ca4bf0278297fc
          Log:
          [FIXED JENKINS-7442] Change ArgumentListBuilder.toWindowsCommand() to not escape %VAR%
          type references by default (can now be done by passing "true" parameter).
          This restores ability to use %VAR% references for ant build steps on windows.

          Originally-Committed-As: 3bd3ff9b572391606300f1ecfcad3eb62792d32d

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: alanharder Path: test/src/test/java/hudson/tasks/AntTest.java war/src/main/webapp/help/ant/ant-properties.html http://jenkins-ci.org/commit/ant-plugin/f84ca39415be5312f9170de5a7ca4bf0278297fc Log: [FIXED JENKINS-7442] Change ArgumentListBuilder.toWindowsCommand() to not escape %VAR% type references by default (can now be done by passing "true" parameter). This restores ability to use %VAR% references for ant build steps on windows. Originally-Committed-As: 3bd3ff9b572391606300f1ecfcad3eb62792d32d

          Code changed in jenkins
          User: alanharder
          Path:
          test/src/test/java/hudson/tasks/AntTest.java
          war/src/main/webapp/help/ant/ant-properties.html
          http://jenkins-ci.org/commit/ant-plugin/e344ba82253b924a2ab3a321be265c400018946c
          Log:
          [FIXED JENKINS-7442] Change ArgumentListBuilder.toWindowsCommand() to not escape %VAR%
          type references by default (can now be done by passing "true" parameter).
          This restores ability to use %VAR% references for ant build steps on windows.

          Originally-Committed-As: c4590529f731ba30b5deb0961d73f76e35ab70ff

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: alanharder Path: test/src/test/java/hudson/tasks/AntTest.java war/src/main/webapp/help/ant/ant-properties.html http://jenkins-ci.org/commit/ant-plugin/e344ba82253b924a2ab3a321be265c400018946c Log: [FIXED JENKINS-7442] Change ArgumentListBuilder.toWindowsCommand() to not escape %VAR% type references by default (can now be done by passing "true" parameter). This restores ability to use %VAR% references for ant build steps on windows. Originally-Committed-As: c4590529f731ba30b5deb0961d73f76e35ab70ff

          Code changed in jenkins
          User: alanharder
          Path:
          changelog.html
          core/src/main/java/hudson/util/ArgumentListBuilder.java
          core/src/test/java/hudson/util/ArgumentListBuilderTest.java
          test/src/test/java/hudson/tasks/AntTest.java
          war/src/main/webapp/help/ant/ant-properties.html
          http://jenkins-ci.org/commit/jenkins/3bd3ff9b572391606300f1ecfcad3eb62792d32d
          Log:
          [FIXED JENKINS-7442] Change ArgumentListBuilder.toWindowsCommand() to not escape %VAR%
          type references by default (can now be done by passing "true" parameter).
          This restores ability to use %VAR% references for ant build steps on windows.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: alanharder Path: changelog.html core/src/main/java/hudson/util/ArgumentListBuilder.java core/src/test/java/hudson/util/ArgumentListBuilderTest.java test/src/test/java/hudson/tasks/AntTest.java war/src/main/webapp/help/ant/ant-properties.html http://jenkins-ci.org/commit/jenkins/3bd3ff9b572391606300f1ecfcad3eb62792d32d Log: [FIXED JENKINS-7442] Change ArgumentListBuilder.toWindowsCommand() to not escape %VAR% type references by default (can now be done by passing "true" parameter). This restores ability to use %VAR% references for ant build steps on windows.

          Code changed in jenkins
          User: alanharder
          Path:
          changelog.html
          core/src/main/java/hudson/util/ArgumentListBuilder.java
          core/src/test/java/hudson/util/ArgumentListBuilderTest.java
          test/src/test/java/hudson/tasks/AntTest.java
          war/src/main/webapp/help/ant/ant-properties.html
          http://jenkins-ci.org/commit/jenkins/c4590529f731ba30b5deb0961d73f76e35ab70ff
          Log:
          [FIXED JENKINS-7442] Change ArgumentListBuilder.toWindowsCommand() to not escape %VAR%
          type references by default (can now be done by passing "true" parameter).
          This restores ability to use %VAR% references for ant build steps on windows.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: alanharder Path: changelog.html core/src/main/java/hudson/util/ArgumentListBuilder.java core/src/test/java/hudson/util/ArgumentListBuilderTest.java test/src/test/java/hudson/tasks/AntTest.java war/src/main/webapp/help/ant/ant-properties.html http://jenkins-ci.org/commit/jenkins/c4590529f731ba30b5deb0961d73f76e35ab70ff Log: [FIXED JENKINS-7442] Change ArgumentListBuilder.toWindowsCommand() to not escape %VAR% type references by default (can now be done by passing "true" parameter). This restores ability to use %VAR% references for ant build steps on windows.

            mindless Alan Harder
            skorsky skorsky
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: