-
Bug
-
Resolution: Unresolved
-
Critical
-
None
-
Windows Server 2008 R2
Ant 1.8.3
Jenkins 1.491
-
Powered by SuggestiMate
Hi,
any parameterized build that has an ant builder only starts the default ant target and completely ignores the given target in the ant builder options.
So if we have a parameterized build that has to use ant builders we are forced to use the default target or remove the parameter option.
- build.xml
- 15 kB
- config.xml
- 4 kB
- screenshot-1.jpg
- 37 kB
- screenshot-2.jpg
- 71 kB
[JENKINS-15886] parameterized builds start default ant target in Ant-Task
- the parameter is set up via "build is parameterized" Option in the Konfiguration (screenshot1)
- the user selects a certain build to copy artefacts from and this build number is stored in BUILD_SELECTOR Variable
- Later then a copy step copies the artefacts from this build to the workspace (screenshot2)
If the build uses "build is parameterized" option ant builder only starts the default target instead of any other target configured.
Can you attach the config.xml for the job, and an example of of the build output where this occurs.
As looking at the example of the logs(below) I have tested with the copy artifact plugin, I see that the value of BUILD_SELECTOR is added to the ant command.
As I am not a ANT user by default, can you see if that extra parameter(s) passed in is causing the command line to be too long and truncated, and therefore the actual targets are are not included in the cmd.
Also try running the ant command in the log, in a console session as the jenkins user in the workspace for the job and see if
the same occurs.
Building on master in workspace /home/jenkins/jenkins_dev/test Copied 1 artifact from "asdfgh" build number 2 [test] $ /bin/sh -xe /tmp/hudson5015636101750070796.sh + env + grep BUILD_SELECTOR BUILD_SELECTOR=<SpecificBuildSelector plugin="copyartifact@1.25"> <buildNumber>2</buildNumber></SpecificBuildSelector> [test] $ /home/jenkins/.jenkins/tools/Ant/1.8.4/bin/ant '-DBUILD_SELECTOR=<SpecificBuildSelector plugin="copyartifact@1.25"> <buildNumber>2</buildNumber></SpecificBuildSelector>' clean jar Buildfile: /home/jenkins/jenkins_dev/test/build.xml clean: [delete] Deleting directory /home/jenkins/jenkins_dev/test/build compile: [mkdir] Created dir: /home/jenkins/jenkins_dev/test/build/classes [javac] /home/jenkins/jenkins_dev/test/build.xml:19: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 1 source file to /home/jenkins/jenkins_dev/test/build/classes jar: [mkdir] Created dir: /home/jenkins/jenkins_dev/test/build/jar [jar] Building jar: /home/jenkins/jenkins_dev/test/build/jar/HelloWorld.jar BUILD SUCCESSFUL Total time: 3 seconds Finished: SUCCESS
Here is a shortened (only the checkout part is edited ) version of a build-log of that test-build:
Gestartet durch Benutzer Robert Lachner
Building in workspace d:\Dienste\Jenkins\jobs\JENKINS-15886 Parameterized Test\workspace
Deleting project workspace... Cleaning local Directory .
Checking out https://svn.is2.de:8443/svn/standardlife/STL_FlexSTM at revision '2012-12-04T09:24:44.298 +0100'
A .project
A src
A src\STL_FlexSTM.mxml
AU src\playerProductInstall.swf
AU src\shadowframe.png
A src\PageBasisdaten.mxml
A src\de
A src\de\is2
A src\de\is2\navigation
A src\de\is2\navigation\NavigationSTM.as
A src\de\is2\panel
...
A build_properties.xml
A .actionScriptProperties
A html-template
A html-template\AC_OETags.js
AU html-template\playerProductInstall.swf
A html-template\index.template.html
A .settings
A .settings\org.eclipse.core.resources.prefs
A build.xml
AU xmltask.jar
U .
At revision 85
3 Artefakte aus "Standard Life Flex STM" Buildnummer 90 kopiert
[workspace] $ cmd.exe /C '"ant.bat -file build.xml "-DBUILD_SELECTOR=<SavedBuildSelector plugin=""copyartifact@1.25""/>" update_flex_war_test && exit %%ERRORLEVEL%%"'
Buildfile: d:\Dienste\Jenkins\jobs\JENKINS-15886 Parameterized Test\workspace\build.xml
info:
[echo] Build für StandardLife FleX STM
[echo] target 'main' baut die Flex Oberfläche
[echo] target 'update_flex_war_test' und 'update_axis_war_test' editieren die wars für die test-stages
[echo] target 'update_flex_war_test' und 'update_axis_war_test' editieren die wars für die produktiv Umgebung
BUILD SUCCESSFUL
Total time: 0 seconds
[workspace] $ cmd.exe /C '"ant.bat "-DBUILD_SELECTOR=<SavedBuildSelector plugin=""copyartifact@1.25""/>" update_axis_war_test && exit %%ERRORLEVEL%%"'
Buildfile: d:\Dienste\Jenkins\jobs\JENKINS-15886 Parameterized Test\workspace\build.xml
info:
[echo] Build für StandardLife FleX STM
[echo] target 'main' baut die Flex Oberfläche
[echo] target 'update_flex_war_test' und 'update_axis_war_test' editieren die wars für die test-stages
[echo] target 'update_flex_war_test' und 'update_axis_war_test' editieren die wars für die produktiv Umgebung
BUILD SUCCESSFUL
Total time: 0 seconds
Archiviere Artefakte
Finished: SUCCESS
As you can see only the "info" target of the ant build script (i also attached the build.xml) which is the default target is started.
As far as i can see there is no problem with path length or something like that.
But in the config.xml i configured the two targets: 'update_flex_war_test' and 'update_axis_war_test'.
After seeing that you are using Windows to build I set up a windows Node and built my test project from there and see the same thing, and some other strange side effects when selecting different builds to copy from.
Windows only.
Selecting "Specific Build" fails
[test] $ cmd.exe /C '"c:\jenkins\tools\Ant\1.8.4\bin\ant.bat -file build.xml "-DBUILD_SELECTOR=<SpecificBuildSelector plugin=""copyartifact@1.25""> <buildNumber>2</buildNumber></SpecificBuildSelector>" clean jar && exit %%ERRORLEVEL%%"' Buildfile: c:\jenkins\workspace\ant\test\build.xml BUILD FAILED Target "<buildNumber>2</buildNumber></SpecificBuildSelector> clean jar" does not exist in the project "HelloWorld".
Same behaviour occurs when selecting the Perma link
[test] $ cmd.exe /C '"c:\jenkins\tools\Ant\1.8.4\bin\ant.bat -file build.xml "-DBUILD_SELECTOR=<PermalinkBuildSelector plugin=""copyartifact@1.25""> <id>lastFailedBuild</id></PermalinkBuildSelector>" clean jar && exit %%ERRORLEVEL%%"' Buildfile: c:\jenkins\workspace\ant\test\build.xml BUILD FAILED Target "<id>lastFailedBuild</id></PermalinkBuildSelector> clean jar" does not exist in the project "HelloWorld".
Selecting "Status Build" this runs default target as first raised
[test] $ cmd.exe /C '"c:\jenkins\tools\Ant\1.8.4\bin\ant.bat -file build.xml "-DBUILD_SELECTOR=<StatusBuildSelector plugin=""copyartifact@1.25""/>" clean jar && exit %%ERRORLEVEL%%"' Buildfile: c:\jenkins\workspace\ant\test\build.xml clean: [delete] Deleting directory c:\jenkins\workspace\ant\test\build compile: [mkdir] Created dir: c:\jenkins\workspace\ant\test\build\classes [javac] c:\jenkins\workspace\ant\test\build.xml:19: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 1 source file to c:\jenkins\workspace\ant\test\build\classes jar: [mkdir] Created dir: c:\jenkins\workspace\ant\test\build\jar [jar] Building jar: c:\jenkins\workspace\ant\test\build\jar\HelloWorld.jar run: [java] Hello World main: BUILD SUCCESSFUL Total time: 2 seconds
As you can see the strange effects come from the quoting used to pass the variables to the command.
In this case I think that the Copy Artifact Plugin that provides this parameter should be changed so that it is not passed as a string Parameter value. It should really create its own ParameterValue type that does not contribute to the Environment so that these issues do not occur, as in 90% of the cases the parameter is only useful to the copy artifact build step.
(Can't think of others that use it, but I think there might be.)
Therefore setting this to the Copy Artifact Plugin
Will have a look at it when I have time, and to see if changes can be made.
Chris
Pull request submitted
https://github.com/jenkinsci/copyartifact-plugin/pull/13
Parameter escaping issue is also reported in msbuild-plugin (JENKINS-15427).
This is a parameter escaping issue of ant-plugin, and should be fixed in ant-plugin (or might be Jenkins core, I'm not sure how ant-plugin launches native processes).
Can we have some details on how you have the projects set up, and how you pass the parameters to the Ant builder.
As I have tested passing targets to the ant builder and had no problems using ant 1.8.4 and Jenkins 1.491.
were the "targets"=$targets where targets is a string parameter.
Are there parameters passed from a upstream job via parametrised trigger plugin?