1

With respect to the answer at https://stackoverflow.com/a/52371428/2428979

curl -v -g -X POST 'jenkins.url.com/job/UAT/m2release/submit?json{"parameter": [{"name":"ENVIRONMENT", "value":"uat"}, {"name":"MVN_RELEASE_VERSION", "value":"5.23.0-RC2"}, {"name":"MVN_DEV_VERSION", "value":"5.23.0-SNAPSHOT"}, {"name":"MVN_ISDRYRUN", "value":"true"}]}' --user myusername:mypassword

Using the curl request above I am getting the following error on the terminal along with html/css response, please advise.

I have tried various combinations of the command like adding removing flags and modifying the post data, parameters etc but the error remains consistent.

java.lang.NullPointerException
    at org.jvnet.hudson.plugins.m2release.M2ReleaseAction.getString(M2ReleaseAction.java:318)
    at org.jvnet.hudson.plugins.m2release.M2ReleaseAction.doSubmit(M2ReleaseAction.java:223)
    at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
    at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:343)
    at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:184)
    at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:117)
    at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:129)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:734)

1 Answers1

1

Hey @SagarSammy I believe that the problem is in absent query parameters for this invocation. U should specify some other mandatory query parameters except of just json

There are some mandatory query params that have to be present in request, check it out -> https://github.com/jenkinsci/m2release-plugin/blob/master/src/main/java/org/jvnet/hudson/plugins/m2release/M2ReleaseAction.java#L223

json query parameter will be handled a bit lower through the code -> https://github.com/jenkinsci/m2release-plugin/blob/master/src/main/java/org/jvnet/hudson/plugins/m2release/M2ReleaseAction.java#L235

Look at the example that was successful for me:

curl -X POST \
'https://username:token@{your-jenkins-host}/job/some-job/m2release/submit?releaseVersion=2.1.2
&developmentVersion=2.1.3-SNAPSHOT
&isDryRun=on
&scmUsername={your-scm-username}
&scmPassword={your-scm-pwd}
&scmCommentPrefix=[test]
&json={"parameter": {"name":"CUSTOM_PARAM_NAME1", "value": "CUSTOM_PARAM_VAlUE2"}, 
"parameter": {"name":"CUSTOM_PARAM_NAME2", "value": "CUSTOM_PARAM_VAlUE2"}}
&Submit=Schedule Test Maven Release Build \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Jenkins-Crumb: {your-generated-crumb}'

I hope this will help you.

Dzmitry Hubin
  • 1,091
  • 12
  • 14
  • 1
    Thanks @Dzmitry for taking the time out and answering my question. This worked perfectly. – Sagar Sammy Nov 24 '18 at 18:57
  • 1
    For anyone who stumbles across this, just goto the jenkins job webpage enter values and submit while capturing the network request/response headers and create a cUrl based on that! – Sagar Sammy Nov 24 '18 at 19:00