0

I want to get the log for a Jenkins node (enclosingBlock) for one of my jobs.

I know I can get the full log: (replacing jenkinsserver and %JOB% as appropriate)

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

And I can sometimes get a node log with:

http://jenkinsserver/job/%JOB/lastBuild/execution/node/%ID%/log

Though it rarely works/manages to find a log.

With Blue Ocean we can get the logs for just a job, i.e.:

http://jenkinsserver/blue/rest/organizations/jenkins/pipelines/%JOB%/runs/%BUILD%/nodes/%ID%/log/?start=0

But the problem is I want to do this with a perl client. So far I have been successfully able to access the REST API using my perl script, but it is incapable of fetching the blue ocean log URL, it gives a java.lang.NullPointerException returned from the server.

I am using the instructions from Jenkins:

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

And what's confusing is that the curl works for the blue ocean URL, but the perl code does not, thoguh the perl code works for all of the REST API calls that I am making. Any idea on how I need to modify the perl code so that it works even for this Blue Ocean URL?

Here's the error I get from Jenkins when using their LWP perl code and blue ocean log URLs:

 <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)                                                                                                                                                   
  • Can you share the Perl code? Also, I don't see the trace you mention. – chicks Jul 1 at 13:09
  • I used exactly the same code as in the jenkins.io link in my post – David Ljung Madison Stellar Jul 2 at 18:48
  • Rats - forgot to save the trace, I'd need to rewrite the code (I ended up using a curl pipe which I'd rather avoid) if the trace is needed. – David Ljung Madison Stellar Jul 2 at 18:49
  • Did you update the line my $server = 'srvname'; to use your hostname instead of srvname? – chicks Jul 2 at 21:07
  • Yes, everything was updated and was tested with other Jenkins pages, it was just the blue ocean logs that it would get bad access. – David Ljung Madison Stellar Jul 4 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.