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

sh step swallows error output at end of script


    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • durable-task-plugin
    • Jenkins 2.387.3

      Since months oftentimes when a command in a sh step fails the corresponding error message is not visible in the console log of the build. This is quite annoying because you have no idea what the problem is. This is not always the case but often enough that it drives our developers mad.

      We were able to work around it by piping the command output through tee and archive the resulting file with the build. This file always contains the complete command output.

      Here is an example what the console log looks like:
      23:02:00.162 [INFO] Suppression Rule had zero matches: SuppressionRule{packageUrl=PropertyType

      {value=^pkg:maven/org\.yaml/snakeyaml@.*$, regex=true, caseSensitive=false}


      {value=cpe:/a:yaml_project:yaml, regex=false, caseSensitive=false}

      ,}}23:02:00.162 [INFO] Finished Unused Suppression Rule Analyzer (0 seconds)23:02:01.686 [Pipeline] }23:02:01.731 [withMaven] artifactsPublisher - Archive artifact pom.xml under com/knime/enterprise/knime-server-installer/4.17.0-beta-20230515-174122-001629-8048494b/knime-server-installer-4.17.0-beta-20230515-174122-001629-8048494b.pom
      And here is the complete output of the mvn command captured in the file:

      [INFO] Suppression Rule had zero matches: SuppressionRule{packageUrl=PropertyType{value=^pkg:maven/org\.yaml/snakeyaml@.*$, regex=true, caseSensitive=false},cpe={PropertyType{value=cpe:/a:yaml_project:yaml, regex=false, caseSensitive=false},}}
      [INFO] Finished Unused Suppression Rule Analyzer (0 seconds)
      ...<many more lines>...
      [INFO] ------------------------------------------------------------------------ 
      [INFO] Reactor Summary for Aggregator POM for xxx:
      [INFO] Aggregator POM for xxx .......... FAILURE [ 16.375 s]
      [INFO] yyy ............................. SUCCESS [ 7.128 s]
      [INFO] zzz ............................. SUCCESS [ 1.876 s]
      [INFO] ------------------------------------------------------------------------ 
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 27.611 s
      [INFO] Finished at: 2023-05-15T23:02:01+02:00
      [INFO] ------------------------------------------------------------------------ [INFO] [jenkins-event-spy] Generated /home/jenkins/workspace/xxx_master@tmp/withMaven8b3a1417/maven-spy-20230515-230133-7846270225922372218343.log
      [ERROR] Failed to execute goal org.owasp:dependency-check-maven:8.1.0:aggregate (default-cli) on project xxx: One or more exceptions occurred during dependency-check analysis: One or more exceptions occurred during analysis:
      ...<more info about the error>...

      This mostly happens with Maven builds but we also had occassions where Maven was not involved. Unfortunately I was not able yet to create a minimal reproducer.

      The builds run on remote Docker agents in case this is relevant.

      I'm happy to dig deeper but I need some pointers where to start first.


            Unassigned Unassigned
            sithmein Thorsten Meinl
            0 Vote for this issue
            1 Start watching this issue