Guest User

Untitled

a guest
Jun 13th, 2021
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. /**
  2. * Method for getting the ParameterValue instance from ParameterDefinition
  3. * or ParamterAction.
  4. *
  5. * @param paramDefProp ParametersDefinitionProperty
  6. * @param parameterName Name of the Parameter.
  7. * @param paramAction ParametersAction
  8. * @param req StaplerRequest
  9. * @param jo JSONObject
  10. * @return ParameterValue instance of subclass of ParameterValue
  11. */
  12. public ParameterValue getParameterValue(ParametersDefinitionProperty paramDefProp,
  13. String parameterName, ParametersAction paramAction, StaplerRequest req, JSONObject jo) {
  14. ParameterDefinition paramDef;
  15. // this is normal case when user try to rebuild a parameterized job.
  16. if (paramDefProp != null) {
  17. paramDef = paramDefProp.getParameterDefinition(parameterName);
  18. if (paramDef != null) {
  19. // The copy artifact plugin throws an exception when using createValue(req, jo)
  20. // If the parameter comes from the copy artifact plugin, then use the single argument createValue
  21. if (jo.toString().contains("BuildSelector") || jo.toString().contains("WorkspaceSelector")) {
  22. SimpleParameterDefinition parameterDefinition =
  23. (SimpleParameterDefinition)paramDefProp.getParameterDefinition(parameterName);
  24. return parameterDefinition.createValue(jo.getString("value"));
  25. }
  26. return paramDef.createValue(req, jo);
  27. }
  28. }
  29. /*
  30. * when user try to rebuild a build that was invoked by
  31. * parameterized trigger plugin in that case ParameterDefinition
  32. * is null for that parametername that is paased by parameterize
  33. * trigger plugin,so for handling that scenario, we need to
  34. * create an instance of that specific ParameterValue with
  35. * passed parameter value by form.
  36. *
  37. * In contrast to all other parameterActions, ListSubversionTagsParameterValue uses "tag" instead of "value"
  38. */
  39. if (jo.containsKey("value")) {
  40. return cloneParameter(paramAction.getParameter(parameterName), jo.getString("value"));
  41. } else {
  42. return cloneParameter(paramAction.getParameter(parameterName), jo.getString("tag"));
  43. }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment