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

Add pipeline step to print/get the container logs

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: kubernetes-plugin
    • Labels:
      None
    • Similar Issues:

      Description

      The `containerTemplate` is used to run the Jenkins slave and e.g. a `mvn` container to build your code

      It can also be used to e.g. run e.g. a MongoDB in the background that is used by your tests - I guess that is a valid usecase.

      When doing this, it might be useful for debugging purposes to access the logs of the container at some point in the build, before the container terminates - as the user that writes the build might not have access to kubernetes, and also the container will terminate when {{node { }} is finished.

      We suggest adding a pipeline step that takes a container name as argument and either prints the container logs to the build log or returns them:

      def log = containerLog name: "mongo", returnLog: true
      
      containerLog name: "mongo", returnLog: false
      
      // print to log by default
      containerLog "mongo"
      

      We would be willing to implement this ourselves, if you are willing to accept this into the main codebase.

      It might also be worthwhile to add a flag to the `containerTemplate` definition allowing to stream the container logs into the build log when they occur (), in order to be able to easier correlate events from the build with events from the container log..

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                0x89 Martin Sander
                Reporter:
                0x89 Martin Sander
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: