提交 354f3802 编写于 作者: K Kevin Formsma 提交者: Oleg Nenashev

[JENKINS-45519] Fix keepUndefinedParameters option for suppressing warnings (#2939)

* Update ParametersAction.java

Pull request 2687 added a 'false' setting for this flag to prevent warning messages from being logged, but the logic doesn't match the message or the documentation. This updates the check, so that the warning message is correctly suppressed if `hudson.model.ParametersAction.keepUndefinedParameters` is set to false.

* Updated check to use optBoolean
上级 f4d5c764
......@@ -316,8 +316,8 @@ public class ParametersAction implements RunAction2, Iterable<ParameterValue>, Q
return parameters;
}
String shouldKeepFlag = SystemProperties.getString(KEEP_UNDEFINED_PARAMETERS_SYSTEM_PROPERTY_NAME);
if ("true".equalsIgnoreCase(shouldKeepFlag)) {
Boolean shouldKeepFlag = SystemProperties.optBoolean(KEEP_UNDEFINED_PARAMETERS_SYSTEM_PROPERTY_NAME);
if (shouldKeepFlag != null && shouldKeepFlag.booleanValue()) {
return parameters;
}
......@@ -326,7 +326,7 @@ public class ParametersAction implements RunAction2, Iterable<ParameterValue>, Q
for (ParameterValue v : this.parameters) {
if (this.parameterDefinitionNames.contains(v.getName()) || isSafeParameter(v.getName())) {
filteredParameters.add(v);
} else if ("false".equalsIgnoreCase(shouldKeepFlag)) {
} else if (shouldKeepFlag == null) {
LOGGER.log(Level.WARNING, "Skipped parameter `{0}` as it is undefined on `{1}`. Set `-D{2}=true` to allow "
+ "undefined parameters to be injected as environment variables or `-D{3}=[comma-separated list]` to whitelist specific parameter names, "
+ "even though it represents a security breach or `-D{2}=false` to no longer show this message.",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册