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

UnsupportedOperationException getLogFile

    Details

    • Similar Issues:
    • Released As:
      1.23.0-beta-1

      Description

      Whenever the build failure analyser plug-in runs there will be several warnings in the Jenkins log "Avoid calling getLogFile on ..." because getLogFile is deprecated:

      https://javadoc.jenkins.io/plugin/workflow-job/org/jenkinsci/plugins/workflow/job/WorkflowRun.html#getLogFile--

       

      Nov 23, 2018 3:20:04 PM INFO org.jenkinsci.plugins.workflow.job.WorkflowRun finishTestWorkflow/TestWorkflow #362 completed: FAILURE
      Nov 23, 2018 3:20:04 PM WARNING org.jenkinsci.plugins.workflow.job.WorkflowRun getLogFileAvoid calling getLogFile on TestWorkflow/TestWorkflow #362
      java.lang.UnsupportedOperationException
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.getLogFile(WorkflowRun.java:1082)
      	at com.sonyericsson.jenkins.plugins.bfa.BuildFailureScanner.parseSingleLineCauses(BuildFailureScanner.java:426)
      	at com.sonyericsson.jenkins.plugins.bfa.BuildFailureScanner.access$000(BuildFailureScanner.java:77)
      	at com.sonyericsson.jenkins.plugins.bfa.BuildFailureScanner$1.run(BuildFailureScanner.java:289)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      	at java.util.concurrent.FutureTask.run(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      	at java.lang.Thread.run(Unknown Source)
      
      Nov 23, 2018 3:20:04 PM WARNING org.jenkinsci.plugins.workflow.job.WorkflowRun getLogFileAvoid calling getLogFile on TestWorkflow/TestWorkflow #362
      java.lang.UnsupportedOperationException
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.getLogFile(WorkflowRun.java:1082)
      	at com.sonyericsson.jenkins.plugins.bfa.model.MultilineBuildLogFailureReader.scan(MultilineBuildLogFailureReader.java:92)
      	at com.sonyericsson.jenkins.plugins.bfa.BuildFailureScanner.findIndication(BuildFailureScanner.java:451)
      	at com.sonyericsson.jenkins.plugins.bfa.BuildFailureScanner.parseIndication(BuildFailureScanner.java:393)
      	at com.sonyericsson.jenkins.plugins.bfa.BuildFailureScanner.access$100(BuildFailureScanner.java:77)
      	at com.sonyericsson.jenkins.plugins.bfa.BuildFailureScanner$2.run(BuildFailureScanner.java:306)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      	at java.util.concurrent.FutureTask.run(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      	at java.lang.Thread.run(Unknown Source)
      
      Nov 23, 2018 3:20:04 PM WARNING org.jenkinsci.plugins.workflow.job.WorkflowRun getLogFileAvoid calling getLogFile on TestWorkflow/TestWorkflow #362
      java.lang.UnsupportedOperationException
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.getLogFile(WorkflowRun.java:1082)
      	at com.sonyericsson.jenkins.plugins.bfa.model.MultilineBuildLogFailureReader.scan(MultilineBuildLogFailureReader.java:92)
      	at com.sonyericsson.jenkins.plugins.bfa.BuildFailureScanner.findIndication(BuildFailureScanner.java:451)
      	at com.sonyericsson.jenkins.plugins.bfa.BuildFailureScanner.parseIndication(BuildFailureScanner.java:393)
      	at com.sonyericsson.jenkins.plugins.bfa.BuildFailureScanner.access$100(BuildFailureScanner.java:77)
      	at com.sonyericsson.jenkins.plugins.bfa.BuildFailureScanner$2.run(BuildFailureScanner.java:306)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      	at java.util.concurrent.FutureTask.run(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      	at java.lang.Thread.run(Unknown Source)
      
      

        Attachments

          Activity

          Hide
          torstenreinhard Torsten Reinhard added a comment -

          I observed the same Exception

          java.lang.UnsupportedOperationException
                  at org.jenkinsci.plugins.workflow.job.WorkflowRun.getLogFile(WorkflowRun.java:1055)
                  at org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder$BadgeManager.logContains(GroovyPostbuildRecorder.java:257)
          

          caused by this code:

              stage("Check warnings") {
                // check white-list stuff 
                if(manager.logContains(/.*project allows check:.*\\*\\*\\* NOT \\*\\*\\* allowed.*/)) {
                  manager.addWarningBadge("WARNING: ... *** NOT *** allowed: ....detected!")
                  manager.buildUnstable()
                }
              } 

           

          Show
          torstenreinhard Torsten Reinhard added a comment - I observed the same Exception java.lang.UnsupportedOperationException at org.jenkinsci.plugins.workflow.job.WorkflowRun.getLogFile(WorkflowRun.java:1055) at org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder$BadgeManager.logContains(GroovyPostbuildRecorder.java:257) caused by this code: stage( "Check warnings" ) { // check white-list stuff if (manager.logContains(/.*project allows check:.*\\*\\*\\* NOT \\*\\*\\* allowed.*/)) { manager.addWarningBadge( "WARNING: ... *** NOT *** allowed: ....detected!" ) manager.buildUnstable() } }  
          Hide
          gordin Christoph Vogtländer added a comment -

          Torsten Reinhard: you should be able to replace "manager.logContains()" with

          if (currentBuild.rawBuild.log ==~ /(?s).*project allows check:.*\\*\\*\\* NOT \\*\\*\\* allowed.*/) {
          

          Note that this is somewhat different from using "manager.logContains()", as the manager objects internal getMatcher() method matches line after line.

          Access to getLog() must be approved by an administrator when running in a sandbox.

          Btw, the usage of "manager" to add badges/summary is deprecated and should be replaced by the badge plug-in: https://jenkins.io/doc/pipeline/steps/badge/ and https://github.com/jenkinsci/badge-plugin/blob/master/README.md

          Setting the build result without "manager" can be done by using

          currentBuild.result = "UNSTABLE"
          

          See pipeline-syntax/globals reference.

           

          Show
          gordin Christoph Vogtländer added a comment - Torsten Reinhard : you should be able to replace "manager.logContains()" with if (currentBuild.rawBuild.log ==~ /(?s).*project allows check:.*\\*\\*\\* NOT \\*\\*\\* allowed.*/) { Note that this is somewhat different from using "manager.logContains()", as the manager objects internal getMatcher() method matches line after line. Access to getLog() must be approved by an administrator when running in a sandbox. Btw, the usage of "manager" to add badges/summary is deprecated and should be replaced by the badge plug-in: https://jenkins.io/doc/pipeline/steps/badge/ and https://github.com/jenkinsci/badge-plugin/blob/master/README.md Setting the build result without "manager" can be done by using currentBuild.result = "UNSTABLE" See pipeline-syntax/globals reference.  
          Hide
          jons Jon Sten added a comment -
          Show
          jons Jon Sten added a comment - Looks like this issue was fixed by https://github.com/jenkinsci/build-failure-analyzer-plugin/pull/106 .
          Hide
          timja Tim Jacomb added a comment -

          Released as 1.23.0-beta-1

          Show
          timja Tim Jacomb added a comment - Released as 1.23.0-beta-1

            People

            • Assignee:
              timja Tim Jacomb
              Reporter:
              gordin Christoph Vogtländer
            • Votes:
              8 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: