使用RESTful API修改作业的Jenkins构建信息失败,出现内部错误500

z3yyvxxp  于 2023-05-06  发布在  Jenkins
关注(0)|答案(2)|浏览(189)

我试图通过curl使用jenkins的rest API的JSON风格修改作业构建的<keepLog>信息。下面是我在终端中执行的命令:

curl -i -X POST http://userName:passWord@jenkinsServerName/job/jobName/jobNumber/configSubmit -H "Content-Type: application/json" -d '{"keepLog":true}'

在尝试该命令时,我得到以下异常:

HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Expires: 0
Cache-Control: no-cache,must-revalidate
X-Hudson-Theme: default
X-Frame-Options: sameorigin
Set-Cookie: JSESSIONID=E03E57536C73B539AE980D2E2E23E21B; Path=/; HttpOnly
X-Hudson: 1.395
X-Jenkins: 1.532.2
X-Jenkins-Session: 52147858
X-Hudson-CLI-Port: 58895
X-Jenkins-CLI-Port: 58895
X-Jenkins-CLI2-Port: 58895
X-Instance-Identity:    MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk3DSI2DZjwNW5axYcX2GZFGF6k6GjMdrHxJBNdK3jcpMP6B9Va+cj6iEVK8wdrKgr1tr3IbAdmzn0jusEh/CKC1IADwka3FCixrZghZ8kUKVZ82r7LCH34WP8csOEJXgTs13iKgLTEmkmmyQNEYGbfhzDAaFJlWpRuBiReZ0AjcnNnCOJsxqyDjeQMCNkqyTzIIYRSKj+oSseZyhfpUylMVv9ydPm1IuNTwCWZoMYR9Qfs4ggWPmA6T7G8FvQYTLylVbn+D2S44dGFgnvAL0/Sk1kq4hw0OSYyRlnO5PjuLTW3S02p0fjuwCTrgWI5T84pCtBVR3keR9xsgNvsmVoQIDAQAB
X-SSH-Endpoint: idc-ws-arbs-dev.mchp-main.com:58894
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Date: Mon, 26 Oct 2015 05:54:40 GMT
Connection: close

org.apache.commons.jelly.JellyTagException: jar:file:/C:/apache-tomcat-7.0.64/webapps/ROOT/WEB-INF/lib/jenkins-core-1.532.2.jar!/hudson/security/SecurityRealm/loginLink.jelly:28:78: <j:invokeStatic> Could not load class: java.net.URLEncoder. Reason: java.lang.NoSuchMethodException: java.net.URLEncoder.encode(java.lang.Object, java.lang.String) at org.apache.commons.jelly.tags.core.InvokeStaticTag.createLoadClassFailedException(InvokeStaticTag.java:177) at org.apache.commons.jelly.tags.core.InvokeStaticTag.doTag(InvokeStaticTag.java:139) at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269) at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105) at org.kohsuke.stapler.jelly.JellyViewScript.run(JellyViewScript.java:81) at org.kohsuke.stapler.jelly.IncludeTag.doTag(IncludeTag.java:147) at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269) at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105) at org.kohsuke.stapler.jelly.JellyViewScript.run(JellyViewScript.java:81) at org.kohsuke.stapler.jelly.IncludeTag.doTag(IncludeTag.java:147) at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269) at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161) at org.apache.commons.jelly.tags.core.OtherwiseTag.doTag(OtherwiseTag.java:41) at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269) at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:161) at org.apache.commons.jelly.tags.core.ChooseTag.doTag(ChooseTag.java:38) at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:269) at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) at org.apache.commons.jelly.tags.core.CoreTagLibrary$1.run(CoreTagLibrary.java:98) at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99) at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99) at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99) at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99) at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99) at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99) at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99) at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99) at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) at org.kohsuke.stapler.jelly.ReallyStaticTagLibrary$1.run(ReallyStaticTagLibrary.java:99) at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105) at org.kohsuke.stapler.jelly.CallTagLibScript.run(CallTagLibScript.java:120) at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95) at org.apache.commons.jelly.tags.core.CoreTagLibrary$2.run(CoreTagLibrary.java:105) at org.kohsuke.stapler.jelly.JellyViewScript.run(JellyViewScript.java:81) at org.kohsuke.stapler.jelly.DefaultScriptInvoker.invokeScript(DefaultScriptInvoker.java:63) at org.kohsuke.stapler.jelly.DefaultScriptInvoker.invokeScript(DefaultScriptInvoker.java:53) at org.kohsuke.stapler.jelly.JellyFacet$1.dispatch(JellyFacet.java:95) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:728) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:858) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:631) at hudson.init.impl.InstallUncaughtExceptionHandler$1.reportException(InstallUncaughtExceptionHandler.java:25) at org.kohsuke.stapler.compression.CompressionFilter.reportException(CompressionFilter.java:63) at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2522) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2511) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.NoSuchMethodException: java.net.URLEncoder.encode(java.lang.Object, java.lang.String) at java.lang.Class.getMethod(Unknown Source) at org.apache.commons.jelly.tags.core.InvokeStaticTag.doTag(InvokeStaticTag.java:124) ... 69 more

n8ghc7c1

n8ghc7c11#

如果您使用的是Windows,那么您可能对引号有问题:
您可以尝试:

curl -i -X POST http://userName:passWord@jenkinsServerName/job/jobName/jobNumber/configSubmit -H "Content-Type: application/json" -d '{\"keepLog\":true}'

一个相关问题:How to send double quote in -d parameter for curl.exe?

相关问题