What is JJB?
It’s a YAML file
that enable us to write jenkins job description in human readable format and
store in VCS to manage versioning on them.
Who created JJB?
Openstack Infra
team.
Why JJB is created?
Jobs are stored in
CI server in XML format which is not best readable format to write jenkins jobs
manually so they came with JJB to manage jobs at graphical interface level.
Prerequisite:
All these commands should be run on Jenkins server
$ sudo apt-get
install python-yaml
$ sudo apt-get
install python-dev python-pip
$ cd
jenkins-job-builder
$ sudo pip install --user -e .
$ sudo python
setup.py install
Configuration:
$ nano
/etc/jenkins_jobs/jenkins_jobs.ini
[job_builder]
allow_duplicates=True
[jenkins]
user=USERNAME
password=PASSWORD
url=jenkins_url(http://localhost:8080)
Test a YAML job definition:
$ jenkins-jobs test
tests/yamlparser/fixtures/templates002.yaml
The above command
prints the generated Jenkins XML to the console. If you prefer to send it to a directory use
following command.
$ jenkins-jobs test
-o output tests/yamlparser/fixtures/templates002.yaml
The output directory
will contain files with the XML configurations.
Updating Jenkins Jobs:
$ jenkins-jobs --conf
/etc/jenkins_jobs/jenkins_jobs.ini update
tests/yamlparser/fixtures/templates002.yaml
OR
$ jenkins-jobs
update tests/yamlparser/fixtures/templates002.yaml
The above command
will update your Jenkins master with the generated jobs.
Deleting a job:
$ jenkins-jobs
--conf etc/jenkins_jobs.ini delete <job-name>
Reference doc:
http://docs.openstack.org/infra/jenkins-job-builder/quick-start.html
Example: my-job.yaml
- job:
name:
my-first-job-test
description:
"Checking system's uptime and polling job every minute"
project-type:
freestyle
block-downstream:
false
triggers:
- pollscm:
'*/1 * * * *'
builders:
- shell: |
uptime
publishers:
- email:
recipients:
test@test.com
No comments:
Post a Comment