关于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
使用上面的curl请求,我在终端上收到以下错误以及html / css响应,请告知。
我尝试了命令的各种组合,例如添加删除标志以及修改发布数据,参数等,但是错误仍然保持一致。
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)
答案 0 :(得分:0)
嘿@SagarSammy,我相信问题在于此调用缺少查询参数。除了仅json
请求中必须包含一些强制性查询参数,请检出-> https://github.com/jenkinsci/m2release-plugin/blob/master/src/main/java/org/jvnet/hudson/plugins/m2release/M2ReleaseAction.java#L223
json
查询参数将通过以下代码进行处理-> https://github.com/jenkinsci/m2release-plugin/blob/master/src/main/java/org/jvnet/hudson/plugins/m2release/M2ReleaseAction.java#L235
看看对我来说成功的例子:
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}'
我希望这会对您有所帮助。