Jenkins 脚本客户端访问节点/块日志(不是完整日志)。curl 可以工作,但建议的 perl 代码不可以

Jenkins 脚本客户端访问节点/块日志(不是完整日志)。curl 可以工作,但建议的 perl 代码不可以

我想要获取我的一项工作的 Jenkins 节点 (enclosingBlock) 的日志。

我知道我可以获得完整的日志:(根据需要替换 jenkinsserver 和 %JOB%)

http://jenkinsserver/job/%JOB/lastBuild/consoleText

我可以有时获取节点日志:

http://詹金斯服务器/作业/%JOB/lastBuild/执行/节点/%ID%/日志

尽管它很少起作用/设法找到日志。

使用 Blue Ocean 我们可以获取某项工作的日志,例如:

http://詹金斯服务器/blue/rest/organizations/詹金斯/管道/%JOB%/运行/%BUILD%/节点/%ID%/log/?start=0

但问题是我想用 perl 客户端来做这件事。到目前为止,我已经能够使用我的 perl 脚本成功访问 REST API,但它无法获取蓝色海洋日志 URL,它给出了从服务器返回的 java.lang.NullPointerException。

我正在使用詹金斯的指示:

https://www.jenkins.io/doc/book/system-administration/authenticating-scripted-clients/

令人困惑的是,curl 适用于 blue ocean URL,但 perl 代码不适用,尽管 perl 代码适用于我进行的所有 REST API 调用。有没有什么想法我需要如何修改 perl 代码,以便它甚至可以适用于这个 Blue Ocean URL?

这是我在使用他们的 LWP perl 代码和蓝色海洋日志 URL 时从 Jenkins 收到的错误:

 <a bunch of html and then>...
Oops!</span></h1><div id="error-description"><p>A problem occurred while processing the request.                                                                      
Please check <a href="https://jenkins.io/redirect/issue-tracker">our bug tracker</a> to see if a similar problem has already been reported.                                                                                                       
If it is already reported, please vote and put a comment on it to let us gauge the impact of the problem.                        
If you think this is a new issue, please file a new issue.                                                                       
When you file an issue, make sure to add the entire stack trace, along with the version of Jenkins and relevant plugins.                                                                                                                         
<a href="https://jenkins.io/redirect/users-mailing-list">The users list</a> might be also useful in understanding what has happened.<h2>Stack trace</h2><pre style="margin:2em; clear:both">java.lang.NullPointerException                       
at org.kohsuke.stapler.AcceptHeader$StaplerConverterImpl.convert(AcceptHeader.java:224)                                          
at org.kohsuke.stapler.AnnotationHandler.convert(AnnotationHandler.java:66)                                                      
at org.kohsuke.stapler.Header$HandlerImpl.parse(Header.java:67)                                                                  
at org.kohsuke.stapler.Header$HandlerImpl.parse(Header.java:56)                                                                  
at org.kohsuke.stapler.AnnotationHandler.handle(AnnotationHandler.java:91)                                                       
at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:204)                                                                 
at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:145)                                                
at org.kohsuke.stapler.IndexDispatcher.dispatch(IndexDispatcher.java:27)   
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)                                                                         
at org.kohsuke.stapler.MetaClass$2.doDispatch(MetaClass.java:219)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)                                                
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)                                                                 
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:456)                                                                 
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)
at org.kohsuke.stapler.MetaClass$2.doDispatch(MetaClass.java:219)         
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)                                                                                                                                                                                       
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:456)                                                         
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)                                                                      
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)
at org.kohsuke.stapler.MetaClass$2.doDispatch(MetaClass.java:219)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:456)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)
at org.kohsuke.stapler.MetaClass$2.doDispatch(MetaClass.java:219)                             
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)                                                                                                                                                                                           
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:456)                                                                                                                                                                                   
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)                                                                                                                                                                                        
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)                                                                                                                                                                                           
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:456)                                                                                                                                                                                   
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)                                                                                                                                                                                        
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)                                                                                                                                                                                           
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:456)                                                                                                                                                                                   
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)                                                                                                                                                                                        
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)                                                                                                                                                                                           
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:717)                                                                                                                                                                                        
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)                                                                                                                                                                                           
at org.kohsuke.stapler.MetaClass$9.dispatch(MetaClass.java:456)                                                                                                                                                                                   
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:747)                                                                                                                                                                                        
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:878)                                                                                                                                                                                           
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:676)                                                                                                                                                                                           
at org.kohsuke.stapler.Stapler.service(Stapler.java:238)                                                                                                                                                                                          
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)                                                                                                                                                                                   
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:873)                                                                                                                                                                         
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1623)                                                                                                                                                        
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:154)                                                                                                                                                                       
at org.jenkinsci.plugins.ssegateway.Endpoint$SSEListenChannelFilter.doFilter(Endpoint.java:246)                                                                                                                                                   

相关内容