Successfully reported this slideshow.
You’ve unlocked unlimited downloads on SlideShare!
Managing Jenkins with Python
Vijay Kumar B.<email@example.com>
Every developer makes changes to the code and pushes them to the version control system.
The continuous integration server
pulls the code from repository
runs unit tests on the code and verifies its sanity.
Accidentally missed out files are detected early.
Code is verified in a clean room environment.
Code can be tested in various target operating systems and configurations.
Build breakages and unit test breakages are immediately notified.
Continuous Integration Servers
Jenkins - popular continuous integration server written in Java.
Other open source continuous integration servers:
Managing Jenkins jobs through Web UI, does not scale.
Jobs are created by copying an existing job, and modifying it!
Violation of the DRY rule: Don’t Repeat Yourself!
Many people are trying to address the issue in various ways:
Job DSL plugin - https://github.com/jenkinsci/job-dsl-plugin/
Jenkins Job Builder - http://docs.openstack.org/infra/jenkins-job-builder/
Autojenkins - https://github.com/txels/autojenkins
Jenkins provides REST API
Fetch config.xml of existing jobs
Python package that wraps over the REST API
Provides many useful funtions
A template job can be created with place holders.
The job is disabled, which means Jenkins will not run it.
Autojenkins can create new jobs based on the template job, and values specified for the
def create_copy(self, job, template, enable=True, _force=False,
Create a job from a template job.
Description for each project for which CI is required.
summary: Ansible scripts for updating config. and installed
Used to populate the template, and create the jobs.
Per Project Build File
The chunk of what is different across projects in the build steps.
The build steps are put up in a Makefile called .build.mk within the project folder.
The template just invokes a make target in the .build.mk.
As a bonus, the CI build steps are under version control. This is similar to what Travis CI
Script to Update Jobs
A class ProjInfo to hold the per project information.
Script to Update Jobs (Contd.)
The following code creates a job for each project.
jenkins = Jenkins(self._config.jenkins_url,
ci_jobname = "%s-ci" % self._proj_info.name
Job update script itself runs as a job under Jenkins!
Manage over 150 jobs at Zilogic.
Separate release and CI jobs, for each project.