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

Add pipeline step to print/get the container logs

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • kubernetes-plugin
    • None

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

            0x89 Martin Sander
            0x89 Martin Sander
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: