How to write test scenarios in jenkins job builder tasks (yaml)


This article describes useful commands and patterns for testing JJB and YAML related tasks.

Possbile options

Validate job(s)

  1. This option is madatory - all pushed yamls should be valid.
  2. Do not try to validate directly any file which are not maxscale-jobs/*.yaml - it is meaningless.
  3. Before calling validator ensure that your current directory is the root directory of your local maxscale-jenkins-jobs repo.

One job:

cd <maxscale-jenkins-jobs repo root >
../jjg/scripts/ maxscale-jobs/<job_name>.yaml

All jobs (check for errors):

cd <maxscale-jenkins-jobs repo root >
ls -d maxscale_jobs/*.yaml | xargs -I@ sh -c "printf '\nChecking @\n'; ../jjg/scripts/ @ 2>&1" | grep -i error 

All jobs (detailed log view):

cd <maxscale-jenkins-jobs repo root >
ls -d maxscale_jobs/*.yaml | xargs -I@ sh -c "printf '\nChecking @\n'; ../jjg/scripts/ @ 2>&1" | less

Job subset (check for errors):

cd <maxscale-jenkins-jobs repo root >
ls -d maxscale_jobs/*.yaml | grep build | xargs -I@ sh -c "printf '\nChecking @\n'; ../jjg/scripts/ @ 2>&1" | grep -i error 

Expected result - logs does not contain any errors,

Update job


Create if it does not exist, template

Do not update any jobs on max-tst01 without recieving direct and transparent permission from Timofey Turenko.

Update job(s)


cd <maxscale-jenkins-jobs repo root >
../jjg/scripts/ config.maxscale-jenkins.ini update maxscale_jobs/<job_name>.yaml


cd <maxscale-jenkins-jobs repo root >
ls -d maxscale_jobs/*.yaml | grep <pattern> | xargs -I@ sh -c "printf '\nChecking @\n';../jjg/scripts/ config.maxscale-jenkins.ini update  @ 2>&1" | less

You also can to modify by hand already updated job on maxscale-jenkins to replace missing scripts/speed up job execution/recieve needed build status/monitor other repository.

OR you can provide mock job that tests particular aspects of the updated one.

Expected result:
  1. ud_job command output does not contain any errors.
  2. updated job contains all needed settings/build steps/attributes (provide url for job configuration.
  3. updated job behaves as planned (fails in predictable situations, sends emails, calls special scripts and etc.). This can be proofed by providing links for its particular builds.


  1. Scripts for updating and validating jenkins jobs