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

Empty parameterized build properties not quoted when passed to ant

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Blocker
    • Resolution: Fixed
    • Component/s: ant-plugin, core
    • Labels:
    • Environment:
      Jenkins 1.654 ; Jenkins 2.0 ; Jenkins 2.1
      Ant Plugin 1.2
      Windows 7 x86_64 (master and slave)
      Apache Ant 1.9.6
    • Similar Issues:

      Description

      I have a parameterized build job that defines multiple string parameters. The main build step in that job is "Invoke Ant".

      Even though I do not define any "Properties" under "Invoke Ant", all of my job parameters are being passed to ant using "-D<Name>=<Value>". That is fine, except when one of my string parameters is blank. In that case Jenkins passes ant "-D<Name>=", which causes ant to barf.

      If a job parameter is blank then either it should not be passed to ant, or (probably better) a quoted empty string ("") should be passed to ant.

      Attached are a trivial ant build.xml and Jenkins config.xml that demonstrate the problem.

      Here is a sample Console Output:

      Building remotely on iqautobuild14 in workspace F:\Jenkins\workspace\AntJobWithProperty
      [AntJobWithProperty] $ cmd.exe /C "F:\Jenkins\tools\hudson.tasks.Ant_AntInstallation\Ant_from_Apache_\bin\ant.bat -DMY_VAR= && exit %%ERRORLEVEL%%"
      Missing value for property MY_VAR
      Build step 'Invoke Ant' marked build as failure
      Finished: FAILURE

      Note that this issue appears to be the same as JENKINS-5157 and JENKINS-7204 (among others), but those issues are supposedly fixed already. Either there is a subtle difference here that I do not understand, or Jenkins has suffered a regression.

        Attachments

        1. build.xml
          0.1 kB
        2. config.xml
          1 kB

          Issue Links

            Activity

            kcurrier Keith Currier created issue -
            Hide
            chrisvesters Chris Vesters added a comment - - edited

            We are facing the same problem after an upgrade to 1.654

            This looks like a regression, if I compare the old commands with the new one you can clearly see the difference. Before the command was being extra quoted with single quotes, and an empty value would become an empty string (surrounded by double quotes):

            [hudson_ant] $ cmd.exe /C '" -Dparam="" "'
            

            These extra single quotes are gone now, and the empty value is just empty.

            [hudson_ant] $ cmd.exe /C " -Dparam= "
            

            I have tried setting both "" and '' as a value. In the first case the resulting command has invalid syntax, in the second case the value was causing problems further down along the line of our process. This means that this bug is a real killer for us, as we can now only delete the parameter completely.

            Show
            chrisvesters Chris Vesters added a comment - - edited We are facing the same problem after an upgrade to 1.654 This looks like a regression, if I compare the old commands with the new one you can clearly see the difference. Before the command was being extra quoted with single quotes, and an empty value would become an empty string (surrounded by double quotes): [hudson_ant] $ cmd.exe /C '" -Dparam="" "' These extra single quotes are gone now, and the empty value is just empty. [hudson_ant] $ cmd.exe /C " -Dparam= " I have tried setting both "" and '' as a value. In the first case the resulting command has invalid syntax, in the second case the value was causing problems further down along the line of our process. This means that this bug is a real killer for us, as we can now only delete the parameter completely.
            Hide
            ppaczyn Piotr Paczyński added a comment -

            Same here. Due to this issue we're unable to upgrade to 1.654.

            Show
            ppaczyn Piotr Paczyński added a comment - Same here. Due to this issue we're unable to upgrade to 1.654.
            benapgar Ben Apgar made changes -
            Field Original Value New Value
            Link This issue is related to JENKINS-33727 [ JENKINS-33727 ]
            escoem Emilio Escobar made changes -
            Assignee Emilio Escobar [ escoem ]
            escoem Emilio Escobar made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            danielbeck Daniel Beck made changes -
            Comment [ [~escoem] FYI another one. ]
            danielbeck Daniel Beck made changes -
            Labels regression
            Hide
            belpk K P added a comment -

            Jenkins has indeed has suffered a regression. (I don't know when it started; I'm using 1.656 but skipped some intermediate updates)

            Previous jenkins versions passed empty parameters to ant quoted as:
            -Dparam=""

            Version 1.656 passes them as:
            -Dparam=

            Now this fails ant horribly, because subsequent command line argument get parsed by ant as ant target ; which of course makes no sense, and fails the whole thing.

            Show
            belpk K P added a comment - Jenkins has indeed has suffered a regression. (I don't know when it started; I'm using 1.656 but skipped some intermediate updates) Previous jenkins versions passed empty parameters to ant quoted as: -Dparam="" Version 1.656 passes them as: -Dparam= Now this fails ant horribly, because subsequent command line argument get parsed by ant as ant target ; which of course makes no sense, and fails the whole thing.
            belpk K P made changes -
            Priority Major [ 3 ] Blocker [ 1 ]
            Hide
            escoem Emilio Escobar added a comment -

            The fix is under testing and I hope will release as ant plugin version

            Show
            escoem Emilio Escobar added a comment - The fix is under testing and I hope will release as ant plugin version
            escoem Emilio Escobar made changes -
            Link This issue depends on JENKINS-34308 [ JENKINS-34308 ]
            escoem Emilio Escobar made changes -
            Remote Link This issue links to "PR (Web Link)" [ 14214 ]
            escoem Emilio Escobar made changes -
            Link This issue depends on JENKINS-34308 [ JENKINS-34308 ]
            belpk K P made changes -
            Environment Jenkins 1.654
            Ant Plugin 1.2
            Windows 7 x86_64 (master and slave)
            Apache Ant 1.9.6
            Jenkins 1.654 ; Jenkins 2.0 ; Jenkins 2.1
            Ant Plugin 1.2
            Windows 7 x86_64 (master and slave)
            Apache Ant 1.9.6
            Hide
            belpk K P added a comment -

            Any news on this? It's been broken for > 1 month by now ; and it seems the cause has been found quite early on and a fix has been implemented and is proposed ?
            ... But seems no-one is bothering reviewing or accepting the pending fix for weeks now?

            So this blocker seems to be hanging around needlessly with a quick solution at hand?

            This blocker IS simply blocking us to make the transition to Jenkins 2.x , so it's not just an issue in some plugin, but hindering the strategic evolution of jenkins...

            Show
            belpk K P added a comment - Any news on this? It's been broken for > 1 month by now ; and it seems the cause has been found quite early on and a fix has been implemented and is proposed ? ... But seems no-one is bothering reviewing or accepting the pending fix for weeks now? So this blocker seems to be hanging around needlessly with a quick solution at hand? This blocker IS simply blocking us to make the transition to Jenkins 2.x , so it's not just an issue in some plugin, but hindering the strategic evolution of jenkins...
            Hide
            krachynski Ken Rachynski added a comment -

            I just encountered this bug this week after upgrading my LTS installation to 1.651.1. Rolling back to LTS 1.642.4 fixed the issue for me, but LTS is supposed to be stable, eh?

            Show
            krachynski Ken Rachynski added a comment - I just encountered this bug this week after upgrading my LTS installation to 1.651.1. Rolling back to LTS 1.642.4 fixed the issue for me, but LTS is supposed to be stable, eh?
            benapgar Ben Apgar made changes -
            Link This issue is related to JENKINS-7204 [ JENKINS-7204 ]
            benapgar Ben Apgar made changes -
            Link This issue is duplicated by JENKINS-34325 [ JENKINS-34325 ]
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Emilio Escobar
            Path:
            .gitignore
            src/main/java/hudson/tasks/Ant.java
            src/test/java/hudson/tasks/AntTest.java
            http://jenkins-ci.org/commit/ant-plugin/b6956b51c8c429b4690a7a1565386da64c15801c
            Log:
            JENKINS-33712 Fixed regression issue with empty parameters.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Emilio Escobar Path: .gitignore src/main/java/hudson/tasks/Ant.java src/test/java/hudson/tasks/AntTest.java http://jenkins-ci.org/commit/ant-plugin/b6956b51c8c429b4690a7a1565386da64c15801c Log: JENKINS-33712 Fixed regression issue with empty parameters.
            Hide
            escoem Emilio Escobar added a comment -

            Finally the code has been merged.

            Show
            escoem Emilio Escobar added a comment - Finally the code has been merged.
            Hide
            escoem Emilio Escobar added a comment -

            Hi, the 1.3 version has been released. Keith Currier, can you try it, please?

            Show
            escoem Emilio Escobar added a comment - Hi, the 1.3 version has been released. Keith Currier , can you try it, please?
            Hide
            krachynski Ken Rachynski added a comment -

            I can report that I upgraded my LTS system and ant builds are running properly with 1.3.

            Show
            krachynski Ken Rachynski added a comment - I can report that I upgraded my LTS system and ant builds are running properly with 1.3.
            Hide
            kcurrier Keith Currier added a comment -

            Looks good. I tried Ant Plugin 1.3 with Jenkins 2.1, 2.2, and 2.3. In all cases, the behavior was as expected.

            Thanks for the help!

            Show
            kcurrier Keith Currier added a comment - Looks good. I tried Ant Plugin 1.3 with Jenkins 2.1, 2.2, and 2.3. In all cases, the behavior was as expected. Thanks for the help!
            Hide
            escoem Emilio Escobar added a comment -

            Thanks to all!

            Show
            escoem Emilio Escobar added a comment - Thanks to all!
            escoem Emilio Escobar made changes -
            Status In Progress [ 3 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 169681 ] JNJira + In-Review [ 198659 ]

              People

              • Assignee:
                escoem Emilio Escobar
                Reporter:
                kcurrier Keith Currier
              • Votes:
                8 Vote for this issue
                Watchers:
                16 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: