Answers: <ul>
  <li>You can use a script (e.g., Python, Shell) to <strong>trigger Jenkins jobs via the Jenkins API</strong>, collect the reports, and aggregate them.</li>
  <li>You will probably need to install some reporting/publishing plugins like Jacoco or Junit.</li>
  </ul>
  <h3>Example Python Script</h3>
  <p>Here’s a simple example using Python:</p>
  <pre><code>import requests
  
  jenkins_url = 'http://your-jenkins-url'
  job_names = [
      'repo1-unit-tests',
      'repo2-unit-tests',
      'repo3-unit-tests',
      # Add more job names as needed
  ]
  cumulative_report = ''
  
  for job in job_names:
      response = requests.get(f'{jenkins_url}/job/{job}/lastBuild/artifact/target/site/jacoco/index.html')
      cumulative_report += response.text
  
  with open('cumulative-report.html', 'w') as f:
      f.write(cumulative_report)
  
  </code></pre>
  <p><strong>Key Points:</strong></p>
  <ol>
  <li><strong>Script-based Approach</strong>: Utilize a script (Python, Shell, etc.) to manage Jenkins jobs.</li>
  <li><strong>Jenkins API</strong>: Leverage the Jenkins API to trigger jobs and fetch results.</li>
  <li><strong>Aggregate Reports</strong>: Collect and aggregate reports from multiple Jenkins jobs.</li>
  <li><strong>Output</strong>: Save the aggregated report into a single HTML file.</li>
  </ol>
  <ul>
  <li>You can use a database to store all the results and an excel python module to format your excel files.</li>
  <li>This method ensures an automated and consolidated way to handle and review test reports from various Jenkins jobs.</li>
  </ul>
  
Answers: CC BY-SA 4.0
Answers: 2024-08-16T16:24:12.953Z
Answers: 2024-08-16T16:24:12.953Z
Answers: YassineLbk
Body: <p>We use separate Jenkins jobs to collect unit tests and coverage for each repository. There are 32 such repos. How do we collect cumulative report?</p>
  <p>Currently we are going into each job and collecting the report manually for each repository. Typically it takes 90 minutes to complete this process as we maintain in a table or an Excel and send it to team. We need to automate this to save our efforts.</p>
  
Tags: <jenkins><jenkins-pipeline><python><jenkinsfile><shell-script>
Title: How to collect cumulative report for 32 repos?
UserDisplayName: TheDevOpsMonk
ThreadText: # How to collect cumulative report for 32 repos?
  
  (Asked by: username_0 on 2024-03-24)
  
  We use separate Jenkins jobs to collect unit tests and coverage for each repository. There are 32 such repos. How do we collect cumulative report?
  
  Currently we are going into each job and collecting the report manually for each repository. Typically it takes 90 minutes to complete this process as we maintain in a table or an Excel and send it to team. We need to automate this to save our efforts.
  
  **Tags:** jenkins, jenkins-pipeline, python, jenkinsfile, shell-script
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-08-16. Score: 0
  
  * You can use a script (e.g., Python, Shell) to **trigger Jenkins jobs via the Jenkins API**, collect the reports, and aggregate them.
  * You will probably need to install some reporting/publishing plugins like Jacoco or Junit.
  
  ### Example Python Script
  
  Here’s a simple example using Python:
  
  ```
  import requests
  
  jenkins_url = 'http://your-jenkins-url'
  job_names = [
      'repo1-unit-tests',
      'repo2-unit-tests',
      'repo3-unit-tests',
      # Add more job names as needed
  ]
  cumulative_report = ''
  
  for job in job_names:
      response = requests.get(f'{jenkins_url}/job/{job}/lastBuild/artifact/target/site/jacoco/index.html')
      cumulative_report += response.text
  
  with open('cumulative-report.html', 'w') as f:
      f.write(cumulative_report)
  
  ```
  
  **Key Points:**
  
  1. **Script-based Approach**: Utilize a script (Python, Shell, etc.) to manage Jenkins jobs.
  2. **Jenkins API**: Leverage the Jenkins API to trigger jobs and fetch results.
  3. **Aggregate Reports**: Collect and aggregate reports from multiple Jenkins jobs.
  4. **Output**: Save the aggregated report into a single HTML file.
  
  * You can use a database to store all the results and an excel python module to format your excel files.
  * This method ensures an automated and consolidated way to handle and review test reports from various Jenkins jobs.
  
  
  ---
  
  