• Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • ant-plugin
    • None
    • Windows

      Passing the Hudson env var $WORKSPACE to Ant stopped working. I had my Ant build working and after upgrading, it stopped building in the workspace. After some debugging, it appears that Hudson doesn't replace $WORKSPACE with the env var value when calling Ant. I had to change my Ant script to get ${env.WORKSPACE} instead.
      Previously, I had defined the variable in Hudson like this as : myvar=$WORKSPACE and this worked.

      Both methods are described here : http://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-AntScripts

          [JENKINS-6013] Passing Hudson env vars to Ant stopped working

          km added a comment -

          I am not sure if this is reproducible. In my ANT build script, I put:
          <echo message="Property of myvar is: ${myvar}"/>

          and I defined the project's properties as:

          myvar=$WORKSPACE

          and in the build output, it echoes it correctly.

          Also, the actual ANT build is run as follows:
          ant -file build.xml -Dmyvar=$WORKSPACE

          Ah, this might be Windows specific? (I tried on Linux and it works as expected).

          km added a comment - I am not sure if this is reproducible. In my ANT build script, I put: <echo message="Property of myvar is: ${myvar}"/> and I defined the project's properties as: myvar=$WORKSPACE and in the build output, it echoes it correctly. Also, the actual ANT build is run as follows: ant -file build.xml -Dmyvar=$WORKSPACE Ah, this might be Windows specific? (I tried on Linux and it works as expected).

          tsug added a comment -

          I have problems also with Ant and my own env variables: (Linux)

          Steps (Execute Shell and Ant):

          • In Execute Shell I set variable:

          export VAR_X=value_y

          • In build.xml:

          <property environment="env" />
          <property name="my.var" value="${env.VAR_X}"/>
          <echo>VALUE: ${my.var}</echo>

          • Ant debug message in console view:

          Setting project property: my.var -> ${env.VAR_X}

          • [echo] VALUE: ${env.VAR_X}

          So my own environment variable(s) cannot passed to Ant script. Note! ${env.SVN_REVISION} and ${env.BUILD_URL} are passed OK.

          Poor man's very poor workaround solution is to write environment variable to build.properties file in Execute Shell step and use it in build.xml

          • build.properties:
            my.var=value_y
          • build.xml

          <property file="build.properties"/>

          tsug added a comment - I have problems also with Ant and my own env variables: (Linux) Steps (Execute Shell and Ant): In Execute Shell I set variable: export VAR_X=value_y In build.xml: <property environment="env" /> <property name="my.var" value="${env.VAR_X}"/> <echo>VALUE: ${my.var}</echo> Ant debug message in console view: Setting project property: my.var -> ${env.VAR_X} [echo] VALUE: ${env.VAR_X} So my own environment variable(s) cannot passed to Ant script. Note! ${env.SVN_REVISION} and ${env.BUILD_URL} are passed OK. Poor man's very poor workaround solution is to write environment variable to build.properties file in Execute Shell step and use it in build.xml build.properties: my.var=value_y build.xml <property file="build.properties"/>

            plentz Diego Plentz
            mjstrecker mjstrecker
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: