DEV Community

Cover image for Execute all JMeter files with GitHUB Actions
Boga Sebastian Nicolae
Boga Sebastian Nicolae

Posted on

Execute all JMeter files with GitHUB Actions

I created a github workflow to be able to run all jmx files from my repository.

Image description

The workflow is triggered on push [main]. The machine provided by github is an ubuntu machine. Once we have the machine up and running with the operating system:

My Workflow

  1. checkout actions/checkout@v2
  2. displays the current folder (you can refer to this folder like this $GITHUB_WORKSPACE)
  3. install the JMeter version 5.4.1 (here we also display the jmeter version and also the current folder location)
  4. 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)
  5. run each jmx file from the repo

Submission Category:

Maintainer Must-Haves
DIY Deployments

Yaml File or Link to Code

GitHub logo 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]





# This is a workflow to help you run all JMeter scripts with Actions

name: jmeter

# 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

      # 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/apache-jmeter-5.4.1/bin
         for i in $( ls $GITHUB_WORKSPACE/*.jmx); do
            ./jmeter -n -t $i;
         done
Enter fullscreen mode Exit fullscreen mode

Additional Resources / Info

For now we do not keep the artifacts, but for sure in next version I'll add another step in the workflow so we can have also the artifacts generated by JMeter.

Discussion (0)