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

Log Parser Plugin does not parse Pipeline console outputs

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Versions:

      • Jenkins: 1.644
      • Workflow plugins: 1.12
      • Log Parser Plugin: 2.0

      Issue:
      I have the following workflow job:

      node {
         step([$class: 'LogParserPublisher', parsingRulesPath: '/var/lib/jenkins/jenkins-rule-logparser', useProjectRule: false])
         echo 'Error: oh no'
      }
      

      and it produces the following console output:

      Started by user anonymous
      [Workflow] Allocate node : Start
      Running on master in /var/lib/jenkins/jobs/ntsvc-monitor-dev/workspace
      [Workflow] node {
      [Workflow] step
      [Workflow] echo
      Error: oh noes
      [Workflow] } //node
      [Workflow] Allocate node : End
      [Workflow] End of Workflow
      Finished: SUCCESS
      

      The log parser config (/var/lib/jenkins/jenkins-rule-logparser) is:

      error /Error/
      

      The parsed log view shows only:

      Started by user anonymous
      [Workflow] Allocate node : Start
      Running on master in /var/lib/jenkins/jobs/ntsvc-monitor-dev/workspace
      [Workflow] node {
      

      For a FreeStyle job, the same echo message and log parser rules, results in fully parsed log and the error message is detected/colored red. See attachments for views of parsed log screens.

      The Jenkins system log does not contain errors for the jobs or the Log Parse plugin... indeed, it contains success messages from the Log Parse plugin.

        Attachments

          Activity

          Hide
          fx576 Pierre Marton added a comment -

          You can of course

          I don't see why it wouldn't work, just try.

          Show
          fx576 Pierre Marton added a comment - You can of course I don't see why it wouldn't work, just try.
          Hide
          martin55 Martin Dan added a comment -

          Hi all!
          In my pipeline i have problem. Job failed in this stage(log-parser)

          pipeline {
          agent

          { label 'master' }

          triggers

          { pollSCM('* * * * *') }

          environment

          { ANSIBLE_CONFIG = "Jenkins-LTS/ansible.cfg" }

          ..........

          stage('Log-parser') {
          steps {
          logparser([$class: 'LogParserPublisher',
          parsingRulesPath: '/var/lib/jenkins/minimal-rules',
          useProjectRule: false,
          failBuildOnError: true,
          unstableOnWarning: false,
          Logparsergraphs: true ])

          error:
          java.lang.NoSuchMethodError: No such DSL method 'logparser' found among steps ....... and more string

          Show
          martin55 Martin Dan added a comment - Hi all! In my pipeline i have problem. Job failed in this stage(log-parser) pipeline { agent { label 'master' } triggers { pollSCM('* * * * *') } environment { ANSIBLE_CONFIG = "Jenkins-LTS/ansible.cfg" } .......... stage('Log-parser') { steps { logparser([$class: 'LogParserPublisher', parsingRulesPath: '/var/lib/jenkins/minimal-rules', useProjectRule: false, failBuildOnError: true, unstableOnWarning: false, Logparsergraphs: true ]) error: java.lang.NoSuchMethodError: No such DSL method 'logparser' found among steps ....... and more string
          Hide
          fx576 Pierre Marton added a comment -

          Well what about the end of the stage?

          } catch(all)

          { print "ERROR: LogParserPublisher failed: \n" +all }

          }
          }

          Would be easier to help you if you put the all code in (at least the complete stage).

          Show
          fx576 Pierre Marton added a comment - Well what about the end of the stage? } catch(all) { print "ERROR: LogParserPublisher failed: \n" +all } } } Would be easier to help you if you put the all code in (at least the complete stage).
          Hide
          martin55 Martin Dan added a comment -

          Hi! Thx for answer. her is cod

          pipeline

          { agent \{ label 'master'}

          triggers

          { pollSCM('* * * * *') }

          environment

          { ANSIBLE_CONFIG = "Jenkins-LTS/ansible.cfg" }

          stages{
          stage('Checkout') {
          steps

          { checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'Jenkins-LTS'], [$class: 'WipeWorkspace']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'fd864bf0-5e33-4cf1-a130-67ac2c22bf17', url: 'https://github.com/MRDO5/jenkins-lts.git']]]) }

          }
          stage('Deploy') {
          parallel {
          stage('Syntax check') {
          steps {
          ansiColor('gnome-terminal')

          { ansiblePlaybook become: true, colorized: true, credentialsId: '7980492c-7fa3-41b6-9c8e-b44d3f7ce236', extras: '--syntax-check' , inventory: 'Jenkins-LTS/inventory', playbook: 'Jenkins-LTS/main.yml' }

          }
          }
          stage('Check provision for virtual machines') {
          steps {
          ansiColor('gnome-terminal')

          { ansiblePlaybook become: true, colorized: true, credentialsId: '7980492c-7fa3-41b6-9c8e-b44d3f7ce236', installation: 'ansible', inventory: 'Jenkins-LTS/inventory', playbook: 'Jenkins-LTS/main.yml' }

          }
          }
          }
          }
          stage('Log-parser') {
          steps

          { logparser([$class: 'LogParserPublisher', parsingRulesPath: '/var/lib/jenkins/minimal-rules', useProjectRule: false, failBuildOnError: true, unstableOnWarning: false, Logparsergraphs: true ]) }

          }
          }

           

          Show
          martin55 Martin Dan added a comment - Hi! Thx for answer. her is cod pipeline { agent \{ label 'master'} triggers { pollSCM('* * * * *') } environment { ANSIBLE_CONFIG = "Jenkins-LTS/ansible.cfg" } stages{ stage('Checkout') { steps { checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'Jenkins-LTS'], [$class: 'WipeWorkspace']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'fd864bf0-5e33-4cf1-a130-67ac2c22bf17', url: 'https://github.com/MRDO5/jenkins-lts.git']]]) } } stage('Deploy') { parallel { stage('Syntax check') { steps { ansiColor('gnome-terminal') { ansiblePlaybook become: true, colorized: true, credentialsId: '7980492c-7fa3-41b6-9c8e-b44d3f7ce236', extras: '--syntax-check' , inventory: 'Jenkins-LTS/inventory', playbook: 'Jenkins-LTS/main.yml' } } } stage('Check provision for virtual machines') { steps { ansiColor('gnome-terminal') { ansiblePlaybook become: true, colorized: true, credentialsId: '7980492c-7fa3-41b6-9c8e-b44d3f7ce236', installation: 'ansible', inventory: 'Jenkins-LTS/inventory', playbook: 'Jenkins-LTS/main.yml' } } } } } stage('Log-parser') { steps { logparser([$class: 'LogParserPublisher', parsingRulesPath: '/var/lib/jenkins/minimal-rules', useProjectRule: false, failBuildOnError: true, unstableOnWarning: false, Logparsergraphs: true ]) } } }  
          Hide
          fx576 Pierre Marton added a comment - - edited

          Well I'm using 2 different ways for pipeline code:

          in Jenkins job as last stage:

          stage("Parser") {
          node('master') {
          try 

          { step([$class: 'LogParserPublisher', parsingRulesPath: 'YOUR_PARSING_FILE', useProjectRule: false, failBuildOnError: true, unstableOnWarning: true]) }

          catch(all)

          { print "ERROR: LogParserPublisher failed: \n" +all }

          }
          }

          in Jenkinsfile:
          @Library('pipelib@master')
          import […]

          timestamps {
          try

          { // For finally LogParserPublisher […] }

          finally {
          node

          { step([$class: 'LogParserPublisher', parsingRulesPath: 'YOUR_PARSING_FILE', useProjectRule: false]) }

          }
          }

          The only difference with your code is that your parsing step is missing
          try {} / catch(all) {}
          or try {} / finally {}

          Also not sure how Ansible affects it as I'm not using it.

          Show
          fx576 Pierre Marton added a comment - - edited Well I'm using 2 different ways for pipeline code: in Jenkins job as last stage: stage("Parser") { node('master') { try  { step([$class: 'LogParserPublisher', parsingRulesPath: 'YOUR_PARSING_FILE', useProjectRule: false, failBuildOnError: true, unstableOnWarning: true]) } catch(all) { print "ERROR: LogParserPublisher failed: \n" +all } } } in Jenkinsfile: @Library('pipelib@master') import […] timestamps { try { // For finally LogParserPublisher […] } finally { node { step([$class: 'LogParserPublisher', parsingRulesPath: 'YOUR_PARSING_FILE', useProjectRule: false]) } } } The only difference with your code is that your parsing step is missing try {} / catch(all) {} or try {} / finally {} Also not sure how Ansible affects it as I'm not using it.

            People

            • Assignee:
              mreinhardt Martin Reinhardt
              Reporter:
              potatopankakes Jeff Burke
            • Votes:
              13 Vote for this issue
              Watchers:
              18 Start watching this issue

              Dates

              • Created:
                Updated: