/** * Create a parameter value from a form submission. * * <p> * This method is invoked when the user fills in the parameter values in the HTML form * and submits it to the server. */ @CheckForNull public abstract ParameterValue createValue(StaplerRequest req, JSONObject jo); 这个方法就是在jenkins 的job上 点击 Build with Parameters 时候会调用到这个方法里面.
/** * Create a parameter value from a GET with query string. * If no value is available in the request, it returns a default value if possible, or null. * * <p> * Unlike {@link #createValue(StaplerRequest, JSONObject)}, this method is intended to support * the programmatic POST-ing of the build URL. This form is less expressive (as it doesn't support * the tree form), but it's more scriptable. * * <p> * If a {@link ParameterDefinition} can't really support this mode of creating a value, * you may just always return null. * * @throws IllegalStateException * If the parameter is deemed required but was missing in the submission. */ @CheckForNull public abstract ParameterValue createValue(StaplerRequest req); 这个会在 curl -X POST http://10.0.61.65:8080/jenkins/job/test_extended-choice-parameter/buildWithParameters?param3=123 这样触发的时候调用到这个方法里面.
这个成 GET 也可以触发,curl -X GET http://10.0.61.65:8080/jenkins/job/test_extended-choice-parameter/buildWithParameters?param3=123
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/** * Create a parameter value from the string given in the CLI. * * @param command * This is the command that got the parameter. * @throws AbortException * If the CLI processing should be aborted. Hudson will report the error message * without stack trace, and then exits this command. Useful for graceful termination. * @throws RuntimeException * All the other exceptions cause the stack trace to be dumped, and then * the command exits with an error code. * @since 1.334 */ @CheckForNull public ParameterValue createValue(CLICommand command, String value) throws IOException, InterruptedException { throw new AbortException("CLI parameter submission is not supported for the "+getClass()+" type. Please file a bug report for this"); }