title: Merge multiple jest coverage reports in Jenkins pipeline
body: <p>I have been handed the CI/CD pipeline and my second task is to get some coverage reports in the output.  I am very new to Jenkins so any pointers would be helpful!</p>
  
  <p>I have several microservices being built in the Jenkins pipeline.  Each microservice has a set of jest unit tests. The folder structure is as follows, with the Jenkinsfile at the root</p>
  
  <pre><code>.Jenkinsfile (at the root)
  ./service1/code
  ./service2/code
  ...
  ./serviceN/code
  </code></pre>
  
  <p>During the build stage, Jenkins loops through the subfolders and builds the docker images.  After all of the services are built, there is a unit test stage that loops through each service/folder and executes 
  <code>jest --coverage</code><br>
  Each service outputs a cobertura-coverage.xml file in the folder ./serviceX/coverage/</p>
  
  <p>What I really want is at the end of the unit test stage to combine the individual coverage reports in 
  ./service1/coverage/cobertura-coverage.xml
  ./service2/coverage/cobertura-coverage.xml</p>
  
  <p>and publish the combined coverage results with something like this</p>
  
  <p><code>step([$class: "CoberturaPublisher", coberturaReportFile: "${jestEnrichers[count]}/coverage/cobertura-coverage.xml"])</code></p>
  
  <p>Currently I am running the jest coverage like this</p>
  
  <pre><code>serviceFolders = ['service1','service2'...] 
  
  for(int count=0; count&lt;serviceFolders.size(); count++){
   echo "Attempting to run JEST tests for ${serviceFolders[count]}"
   sh """
     cd "${WORKSPACE}"/"${serviceFolders[count]}";
     npm install
     npm test
    """
  }
  </code></pre>
  
  <p>and I can see the output in the build log for all the services</p>
  
  <p>But I do not know how to combine into one report
  if i execute this</p>
  
  <pre><code>step([$class: "CoberturaPublisher", coberturaReportFile: "${service1/coverage/cobertura-coverage.xml"])
              publishHTML target: [
                allowMissing : false,
                alwaysLinkToLastBuild: false,
                keepAll              : true,
                reportDir            : "output/coverage/jest",
                reportFiles          : "index.html",
                reportName           : "Test Report"
              ]
  </code></pre>
  
  <p>I see the coverage report in the jenkins UI for the one service so i thought I could wrap this in the same loop that executes
  like this</p>
  
  <pre><code>serviceFolders = ['service1','service2'...] 
  
  for(int count=0; count&lt;serviceFolders.size(); count++){
   echo "Attempting to run JEST tests for ${serviceFolders[count]}"
   sh """
     cd "${WORKSPACE}"/"${serviceFolders[count]}";
     npm install
     npm test
    """
  }
  step([$class: "CoberturaPublisher", coberturaReportFile: "${serviceFolders[count]/coverage/cobertura-coverage.xml"])
              publishHTML target: [
                allowMissing : false,
                alwaysLinkToLastBuild: false,
                keepAll              : true,
                reportDir            : "output/coverage/jest",
                reportFiles          : "index.html",
                reportName           : "Test Report"
              ]
  </code></pre>
  
  <p>Jenkins is reporting an error and i see the coverage report just for service1</p>
  
  <p>and this error after the first iteration of the loop (before the second service's jest tests are run</p>
  
  <pre><code>
  [Cobertura] Publishing Cobertura coverage results...
  
  [Cobertura] Cobertura coverage report found.
  
  [Pipeline] publishHTML
  [htmlpublisher] Archiving HTML reports...
  [htmlpublisher] Archiving at BUILD level /home/jenkins/workspace/licies-pipeline_pipeline-testing/output/coverage/jest to /var/jenkins_home/jobs/xxx-yyy-policies-pipeline/branches/pipeline-testing/builds/208/htmlreports/Test_20Report
  ERROR: Specified HTML directory '/home/jenkins/workspace/licies-pipeline_pipeline-testing/output/coverage/jest' does not exist.
  [Pipeline] echo
  Attempting to run JEST tests for hqaddress
  </code></pre>