![]() |
|
|
|
|
Change By:
|
centic
(01/Mar/13 3:31 PM)
|
|
Description:
|
For one of my Jobs I need multiple lines of text in one parameter, e.g.
In the parameterized build trigger plugin I specify this parameter with "\n": {quote} PROJECTPROPERTIES=sonar.projectKey=preismonitor-lokal\nsonar.projectName=preismonitor-lokal {quote}
The "\n" correctly passes the parameter with newline characters to an upcoming biuld.
In the build.xml of the jenkins-build, the newlines are stored normally, however there are problems later on if other plugins work with this data because the parameter-type is "StringParameterValue" instead of "TextParameterValue":
{code:xml}<hudson.model.StringParameterValue> <name>PROJECTPROPERTIES</name> <value>sonar.projectKey=preismonitor-lokal sonar.projectName=preismonitor-lokal</value> </hudson.model.StringParameterValue>{code}
E.g. if I use the rebuild-plugin to re-trigger the build later on, it seems to cut off the newlines and pass the string in one single line, which causes the rebuild to fail:
{quote} ... -Dsonar.projectKey=preismonitor-lokalsonar.projectName=preismonitor-lokal ... {quote}
I will attach a
The following
patch
which
creates a TextParameterValue if the value contains newlines. This makes this work
in all cases
locally for me:
{code} diff --git a/src/main/java/hudson/plugins/parameterizedtrigger/PredefinedBuildParameters
.
java b/src/main/java/hudson/plugins/parameterizedtrigger/PredefinedBuildParameters.java index b1cbc73..26f2e50 100644 --- a/src/main/java/hudson/plugins/parameterizedtrigger/PredefinedBuildParameters.java +++ b/src/main/java/hudson/plugins/parameterizedtrigger/PredefinedBuildParameters.java @@ -2,13 +2,14 @@ import hudson.EnvVars; import hudson.Extension; -import hudson.model.AbstractBuild; import hudson.model.Action; -import hudson.model.Descriptor; import hudson.model.ParameterValue; +import hudson.model.TaskListener; +import hudson.model.AbstractBuild; +import hudson.model.Descriptor; import hudson.model.ParametersAction; import hudson.model.StringParameterValue; -import hudson.model.TaskListener; +import hudson.model.TextParameterValue; import java.io.IOException; import java.util.ArrayList; @@ -38,8 +39,14 @@ List<ParameterValue> values = new ArrayList<ParameterValue>(); for (Map.Entry<Object, Object> entry : p.entrySet()) { - values.add(new StringParameterValue(entry.getKey().toString(), - env.expand(entry.getValue().toString()))); + // support multi-line parameters correctly + if(entry.getValue().toString().contains("\n")) { + values.add(new TextParameterValue(entry.getKey().toString(), + env.expand(entry.getValue().toString()))); + } else { + values.add(new StringParameterValue(entry.getKey().toString(), + env.expand(entry.getValue().toString()))); + } } return new ParametersAction(values); {code}
|
|
|
|
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
[email protected].
For more options, visit
https://groups.google.com/groups/opt_out.