Add pipeline step to print/get the container logs

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      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..

            Assignee:
            Martin Sander
            Reporter:
            Martin Sander
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: