title: Running multiple Docker containers from a single Jenkinsfile
body: <p>So I spent the whole day trying to figure out how to configure a simple Jenkins Pipeline with multiple Docker images and I am not happy at all.</p>
  
  <p>I need a few stages (prepare, build, test, docs) executed on a couple of different docker containers (currently I just picked three standard Python containers). And it would be nice if those would run in parallel, but I only found this solution, which combines all stages into a single one (and thus creates a not so informative overview in the Blue Ocean UI): <a href="https://stackoverflow.com/questions/46458941/jenkins-pipeline-across-multiple-docker-images">Jenkins Pipeline Across Multiple Docker Images</a></p>
  
  <p>So I ended up with the configuration below, which is ugly as hell (code repetition everywhere), but more or less creates an good looking overview in the classic UI:</p>
  
  <p><a href="https://i.stack.imgur.com/bcjnn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bcjnn.png" alt="Classic UI stages"></a></p>
  
  <p>A not so informative overview in the Blue Ocean UI</p>
  
  <p><a href="https://i.stack.imgur.com/4OTK0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4OTK0.png" alt="Blue Ocean stages overview"></a></p>
  
  <p>And an acceptable test overview from <code>junit</code>, which combines all the tests from each stage but if any test is failing, the corresponding "version" is shown:</p>
  
  <p><a href="https://i.stack.imgur.com/PYfHB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PYfHB.png" alt="junit"></a></p>
  
  <p>The most annoying thing however is, you cannot see which step has failed. If Python 2.7 fails, everything else is also marked as failed and you don't even see which stage failed.</p>
  
  <p>I tried so many different approaches and I am wondering how this should be done. This should be such a common thing to do with Jenkins, so I guess I have some general misunderstandings in this (for me absolutely new) pipeline/nodes/labels/stages/steps/declarative/scripted/groovy/blueocean stuff...</p>
  
  <p>It should be possible to define a list of docker containers some (maybe customisable stages/steps) for each of them and run them in parallel and having it displayed nicely in Blue Ocean and in Classic UI, shouldn't it?</p>
  
  <pre><code>node {
      stage("Python 2.7.14") {
          checkout scm
          docker.image('python:2.7.14').inside {  // just a dummy for now
              stage("Prepare") { sh 'python --version' }
              stage("Build") { sh 'ls -al' }
          }
      }
      stage("Python 3.5.4") {
          checkout scm
          docker.image('python:3.5.4').inside {
              stage("Prepare") { sh 'python -m venv venv' }
              stage("Build") {
                  sh """
                      . venv/bin/activate
                      make install-dev
                  """
              }
              stage('Test') {
                  sh """
                      . venv/bin/activate
                      make test
                  """
              }
              stage('Docs') {
                  sh """
                      . venv/bin/activate
                      make doc-dependencies
                      cd docs
                      make html
                  """
              }
          }
      }
      stage("Python 3.6.4") {
          checkout scm
          docker.image('python:3.5.4').inside {
              stage("Prepare") { sh 'python -m venv venv' }
              stage("Build") {
                  sh """
                      . venv/bin/activate
                      make install-dev
                  """
              }
              stage('Test') {
                  sh """
                      . venv/bin/activate
                      make test
                  """
              }
              stage('Docs') {
                  sh """
                      . venv/bin/activate
                      make doc-dependencies
                      cd docs
                      make html
                  """
              }
          }
      }
  }
  </code></pre>
  
  <p>Update: this is how it looks like in the Blue Ocean UI when a step fails, int this case "Test" in both Python 3.5.4 and 3.6.4 failed but it looks like everything has failed. 
  <a href="https://i.stack.imgur.com/9lQYg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9lQYg.png" alt="Test step failed"></a></p>
  
  <p>Also the Python 2.7.14 and 3.5.4 stages are collapsed and cannot be viewed separately. If I click on one of them, all the steps are shown in green although in this case <code>. venv/bin/activate make test</code> failed:</p>
  
  <p><a href="https://i.stack.imgur.com/QyevG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QyevG.png" alt="Failed test step is shown in green"></a></p>