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

Provide build wrapper withDockerCompose

XMLWordPrintable

      Currently I've built my own in a custom library

      def call(Closure body) {
          docker.withTool('Default') {
              withPythonEnv('python') {
                  sh 'pip install docker-compose'
                  sh 'docker-compose --no-ansi up -d'
                  try {
                      waitUntil { script { dockerUtils.isReady() } }
                      body()
                  } finally {
                      sh 'docker-compose --no-ansi down'
                  }
              }
          }
      }
      

      The isReady() function is a little complicated - it essentially does

      docker inspect --format '{{json .State}}' $(docker-compose ps -q)
      

      then parses and checks that every container has either Health.Status == 'healthy', or Status == 'running' if there is no healthcheck.

      You could implement something similar, and more configurable, directly.

            jgalego João Galego
            jameshowe James Howe
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: