Execute steps before starting docker container

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

XMLWordPrintable

      Execute steps on the host, after selecting the proper node, and before starting the docker container.

      Minimal code examples (see the added pre directive):

      pipeline {
          agent {
              docker {
                  image 'maven:3-alpine'
                  pre {
                      echo 'Called from the host (outside the container).'
                  }
              }
          }
          stages {
              stage('Build') {
                  steps {
                      echo 'Called from inside the container.'
                  }
              }
          }
      }
      
      pipeline {
          agent none
          stages {
              stage('Build') {
                  agent {
                      docker {
                          image 'maven:3-alpine'
                          pre {
                              echo 'Called from the host (outside the container).'
                          }
                      }
                  }
                  steps {
                      echo 'Called from inside the container.'
                  }
              }
          }
      }
      

      The steps inside pre should be executed prior to executing the first stage/step.

      An alternative name is preRun.

       

            Assignee:
            Unassigned
            Reporter:
            Peter Jonsson
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: