I extended the workflow from GitHUB Actions presented in previous article (execute-all-jmeter-files-with-github-actions) so now we can generate and save the JMeter Test Report with GitHUB Actions.
My Workflow
- checkout actions/checkout@v2
- create test_report
- displays the current folder (you can refer to this folder like this $GITHUB_WORKSPACE)
- install the JMeter version 5.4.1(here we also display the jmeter version and also the current folder location)
- install the plugins for JMeter(here we just install the Dummy Sampler, but you can add any other plugin needed by your jmeter script; you can see all the available plugins here: https://jmeter-plugins.org/files/packages)
- run each jmx file from the repo
- create a folder for each jmx file (for each JMeter Test Plan)
- save jmeter test report(HTML format) in the folder created at previous step
- upload JMeter Test Results for all jmx files as artifact
Submission Category:
Maintainer Must-Haves,
DIY Deployments
Yaml File or Link to Code
sebiboga / jmeter_one
JMeter scripts
jmeter_one
- different JMeter scripts
- GitHUB Actions used to define the workflow to run all jmeter scripts from repository [main branch]
- GitHUB Actions used to define the workflow to run all jmeter scripts from repository and save Test Report as artifact [main branch]
- GitHUB Actions used to define the workflow to run all jmeter scripts from repository, generate JTL file and then generates CSV file from JTL file, and then save JTL&CSV as artifact [main branch]
# This is a workflow to help you run all JMeter scripts with Actions, and save Test Results as artifact
name: jmeter_test_results
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: where are the files?
run: |
pwd
ls
- name: create test_report
run: |
mkdir $GITHUB_WORKSPACE/test_report
# Runs a set of commands using the runners shell
- name: install jmeter
run: |
java -version
wget https://downloads.apache.org//jmeter/binaries/apache-jmeter-5.4.1.zip
unzip apache-jmeter-5.4.1.zip
cd apache-jmeter-5.4.1/bin
./jmeter -v
pwd
- name: install plugins
run: |
cd $GITHUB_WORKSPACE/apache-jmeter-5.4.1
wget -q --no-check-certificate https://jmeter-plugins.org/files/packages/jpgc-dummy-0.4.zip -P .
unzip -o jpgc-dummy-0.4.zip && rm jpgc-dummy-0.4.zip
- name: run jmx scripts
run: |
cd $GITHUB_WORKSPACE
for i in $( ls -A1 *.jmx); do
cd $GITHUB_WORKSPACE/apache-jmeter-5.4.1/bin
mkdir $GITHUB_WORKSPACE/test_report/${i%.jmx}
./jmeter -n -t $GITHUB_WORKSPACE/$i -l $GITHUB_WORKSPACE/${i%.jmx}.jtl -e -o $GITHUB_WORKSPACE/test_report/${i%.jmx}
done
- name: Upload JMeter Test Results
uses: actions/upload-artifact@v2.2.4
with:
name: test_results
path: test_report
Additional Resources / Info
JMeter test results are captured as artifacts for each Workflow Run in GitHUB actions.
This is useful because it's a way to share the test results with your team. They just download the test results and they can see the results.
Top comments (1)
I changed a little bit the script, just in case you want to keep in artifacts also the JTL files generted. So before saving the artifact, I just added this script to the Github Actions:
You can see the full YML file here: