About Jenkins Job Builder
Jenkins jobs are stored in XML format on the Continuous Integration (CI) server which is not the best readable format to write a job manually. That’s why it’s highly preferable to manage jobs via graphic interface.
Jenkins Job Builder (JJB) is a software created by the OpenStack infra team which takes simple descriptions of Jenkins jobs in YAML format and uses them to configure Jenkins. That enables you to manage jobs in human readable text format and store them in a version control system. Also, JJB is able to configure remotly Jenkins with new jobs. By creating a template system, you can easily manage jobs with similar configurations. Also, you can store YAML files into your favorite CSV (called subversion control) to manage versionning on them.
How does it work ?
This is a conceptual picture of the workflow :
First of all, you need to install jenkins-job-builder:
git clone https://github.com/openstack-infra/jenkins-job-builder cd jenkins-job-builder sudo python setup.py install
Configure /etc/jenkins_jobs/jenkins_jobs.ini file :
[jenkins] user=USERNAME password=PASSWORD url=JENKINS_URL
Write now your own YAML file with the job decsription. Before pushing it into Jenkins you could test it by generate a XML file:
jenkins-jobs test my-job.yaml -o .
It’s actually useful if you want to convert current jobs into YAML format and check that XML output is what we have currently on Jenkins Server.
When you are ready, let’s go to update the job on our Jenkins server:
jenkins-jobs --conf /etc/jenkins_jobs/jenkins_jobs.ini update my-job.yaml
Read the official documentation for more informations.
Job example
To picture you why it’s so simple to write a job in YAML, here is an example with eDeploy Unit tests:
- job: name: eDeploy-UnitTests-YAML description: 'Do not edit this job through the web!' project-type: freestyle block-downstream: false scm: - git: skip-tag: false url: git@github.com:enovance/edeploy.git triggers: - pollscm: '@hourly' builders: - shell: | git clean -dxf sloccount --duplicates --wide --details . | fgrep -v .svn > sloccount.sc || : find . -name test\*.py|xargs nosetests --with-xunit --verbose || : find . -name \*.py|egrep -v '^./tests/'|xargs pyflakes > pyflakes.log || : rm -f pylint.log for f in `find . -name \*.py|egrep -v '^./tests/'`; do pylint --output-format=parseable --reports=y $f >> pylint.log done || : python /usr/local/lib/python2.7/dist-packages/clonedigger/clonedigger.py --cpd-output . || : publishers: - warnings: workspace-file-scanners: - file-pattern: pyflakes.log scanner: PyFlakes - junit: results: nosetests.xml - sloccount: pattern: sloccount.sc - violations: cpd: pattern: output.xml pylint: pattern: pylint.log - email: recipients: devops@mycompany.com
Recent contributions
To support more Jenkins plugins, we contributed some JJB publishers. These publishers translate YAML into XML for the following plugins:
- SLOCCount which generates the trend report for SLOCCount, an open source program which counts the number of lines of codes in over 25 different languages.
- Plot which provides generic plotting (or graphing) in Jenkins.
- IRCbot which enable Jenkins to send build notífications via IRC and lets you interact with Jenkins via an IRC bot.
[…] By eNovance Engineering Teams: Manage Jenkins Jobs with YAML […]
[…] eNovance Engineering Teams管理Jeckins Jobs与YAML […]
[…] eNovance Engineering Teams管理Jeckins Jobs与YAML […]
[…] By eNovance Engineering Teams: Manage Jenkins Jobs with YAML […]
[…] eNovance Engineering Teams管理Jeckins Jobs与YAML […]
[…] eNovance Engineering Teams管理Jeckins Jobs与YAML […]
Hi,
Actually i was trying to run the same with the help of docker toolbox on windows 7 . Will these commands change there? What sort of changes i will have to make?
Thanks for the help!
Digging around in the auth code, the cert_string that’s csnaiug this error is coming back empty in the unit tests. The pieces that generate it look to be shell calls to openssl perhaps there’s a dependency on a version there that I’m not up with. I have a copy of openssl version 1.0.0a 1 installed from MacPorts.
Hi, I am using jenkins1.612 and i want to have under the post-build actions if we click on Advanced button to the right, a new option would appear. We need to check the box for “Do not fail the build on empty test results”.
How it would be possible using jenkins job builder.
Thanks,
smukalla.
Thanks. This post was really helpful.