Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-62663

Sending console logs when using Jenkins agents results in: java.lang.IllegalStateException: Jenkins.instance is missing

    • 1.9.4

      We are seeing the following error appear with the newest version of the Splunk plugin (1.9.3) when attempting to run builds. This error ONLY appears if we are sending console logs either through use of sendSplunkConsoleLogs() or by checking the box to do so in the UI for the plugin. It appears it is trying to access jenkins.Instance from the agent, which of course is only possible from the master. We also noticed this mention in the comments of another issue, but it appears to be unrelated to the overall other issue: https://issues.jenkins-ci.org/browse/JENKINS-61452?focusedCommentId=392193&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-392193

      SEVERE: flush log error
      java.lang.IllegalStateException: Jenkins.instance is missing. Read the documentation of Jenkins.getInstanceOrNull to see what you are doing wrong.
      	at jenkins.model.Jenkins.get(Jenkins.java:779)
      	at jenkins.model.Jenkins.getActiveInstance(Jenkins.java:791)
      	at com.splunk.splunkjenkins.SplunkJenkinsInstallation.get(SplunkJenkinsInstallation.java:106)
      	at com.splunk.splunkjenkins.utils.SplunkLogService.sendBatch(SplunkLogService.java:162)
      	at com.splunk.splunkjenkins.console.SplunkTaskListenerFactory.flushLog(SplunkTaskListenerFactory.java:85)
      	at com.splunk.splunkjenkins.console.SplunkTaskListenerFactory.enqueue(SplunkTaskListenerFactory.java:74)
      	at com.splunk.splunkjenkins.console.LabelConsoleLineStream.eol(LabelConsoleLineStream.java:52)
      	at com.splunk.splunkjenkins.console.LabelConsoleLineStream.write(LabelConsoleLineStream.java:34)
      	at java.io.FilterOutputStream.write(FilterOutputStream.java:125)
      	at java.io.PrintStream.write(PrintStream.java:480)
      	at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
      	at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
      	at sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder.java:104)
      	at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:185)
      	at java.io.PrintStream.newLine(PrintStream.java:546)
      	at java.io.PrintStream.println(PrintStream.java:807)
      	at com.checkmarx.jenkins.CxLoggerAdapter.info(CxLoggerAdapter.java:59)
      	at com.cx.restclient.sast.utils.zip.CxZip$1.updateProgress(CxZip.java:33)
      	at com.cx.restclient.sast.utils.zip.Zipper.zipFile(Zipper.java:67)
      	at com.cx.restclient.sast.utils.zip.Zipper.zip(Zipper.java:41)
      	at com.cx.restclient.sast.utils.zip.CxZip.zipWorkspaceFolder(CxZip.java:41)
      	at com.cx.restclient.sast.utils.zip.CxZipUtils.zipWorkspaceFolder(CxZipUtils.java:30)
      	at com.cx.restclient.CxSASTClient.createSASTScan(CxSASTClient.java:106)
      	at com.cx.restclient.CxShragaClient.createSASTScan(CxShragaClient.java:82)
      	at com.checkmarx.jenkins.CxScanCallable.invoke(CxScanCallable.java:90)
      	at com.checkmarx.jenkins.CxScanCallable.invoke(CxScanCallable.java:21)
      	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3069)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:211)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
      	at hudson.remoting.Request$2.run(Request.java:369)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:117)
      	at java.lang.Thread.run(Thread.java:748)
      

      EDIT: We are noticing this issue has only consistently appeared on our maven agent (upstream here: https://catalog.redhat.com/software/containers/openshift3/jenkins-agent-maven-35-rhel7/5ad9139ebed8bd441305ce98)

          [JENKINS-62663] Sending console logs when using Jenkins agents results in: java.lang.IllegalStateException: Jenkins.instance is missing

          Ted Xiao added a comment -

          Thanks for reporting, splunk plugin need handle the remote TaskListener call in plugins such as https://github.com/jenkinsci/checkmarx-plugin/blob/master/src/main/java/com/checkmarx/jenkins/CxScanCallable.java#L33

          Ted Xiao added a comment - Thanks for reporting, splunk plugin need handle the remote TaskListener call in plugins such as https://github.com/jenkinsci/checkmarx-plugin/blob/master/src/main/java/com/checkmarx/jenkins/CxScanCallable.java#L33

          Ted Xiao added a comment - I made a fix via https://github.com/jenkinsci/splunk-devops-plugin/tree/bugfix/JENKINS-62663 could you please verify the snapshot version https://repo.jenkins-ci.org/snapshots/com/splunk/splunkins/splunk-devops/1.9.4-SNAPSHOT/splunk-devops-1.9.4-20200611.154831-1.hpi https://repo.jenkins-ci.org/snapshots/com/splunk/splunkins/splunk-devops-extend/1.9.4-SNAPSHOT/splunk-devops-extend-1.9.4-20200611.154904-1.hpi

          fengxx that appears to have fixed it! Thank you so much for your speedy work and response. Do you know what sort of timeline on which we could expect to see a 1.9.4 release including this change? Just trying to figure out if we should downgrade back to a pre-1.9.0 version while we are waiting or not. Thanks again!

          Josef Hoenzsch added a comment - fengxx that appears to have fixed it! Thank you so much for your speedy work and response. Do you know what sort of timeline on which we could expect to see a 1.9.4 release including this change? Just trying to figure out if we should downgrade back to a pre-1.9.0 version while we are waiting or not. Thanks again!

          Ted Xiao added a comment -

          1.9.4 is released

          Ted Xiao added a comment - 1.9.4 is released

            fengxx Ted Xiao
            jhoenzsch Josef Hoenzsch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: