.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "JENKINS-JOBS" "1" "Mar 31, 2023" "3.11.0" "Jenkins Job Builder" .SH NAME jenkins-jobs \- Jenkins Job Builder Documentation .sp Jenkins Job Builder takes simple descriptions of \fI\%Jenkins\fP jobs in \fI\%YAML\fP or \fI\%JSON\fP format and uses them to configure Jenkins. You can keep your job descriptions in human readable text format in a version control system to make changes and auditing easier. It also has a flexible template system, so creating many similarly configured jobs is easy. .sp To install: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $ pip install \-\-user jenkins\-job\-builder .ft P .fi .UNINDENT .UNINDENT .sp Online documentation: .INDENT 0.0 .IP \(bu 2 \fI\%https://jenkins\-job\-builder.readthedocs.io/en/latest/\fP .UNINDENT .SH DEVELOPERS .sp Bug report: .INDENT 0.0 .IP \(bu 2 \fI\%https://storyboard.openstack.org/#!/project/723\fP .UNINDENT .sp Repository: .INDENT 0.0 .IP \(bu 2 \fI\%https://opendev.org/jjb/jenkins\-job\-builder\fP .UNINDENT .sp Cloning: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git clone https://opendev.org/jjb/jenkins\-job\-builder.git .ft P .fi .UNINDENT .UNINDENT .sp Install pre\-commit from \fI\%https://pre\-commit.com/#intro\fP in order to run some minimal testing on your commits. .sp A virtual environment is recommended for development. For example, Jenkins Job Builder may be installed from the top level directory: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $ virtualenv .venv $ source .venv/bin/activate $ pip install \-r test\-requirements.txt \-e . .ft P .fi .UNINDENT .UNINDENT .sp Patches are submitted via Gerrit at: .INDENT 0.0 .IP \(bu 2 \fI\%https://review.opendev.org\fP .UNINDENT .sp Please do not submit GitHub pull requests, they will be automatically closed. .sp Mailing list: .INDENT 0.0 .IP \(bu 2 \fI\%https://groups.google.com/forum/#!forum/jenkins\-job\-builder\fP .UNINDENT .sp IRC: .INDENT 0.0 .IP \(bu 2 \fB#openstack\-jjb\fP on OFTC .UNINDENT .sp More details on how you can contribute is available on our wiki at: .INDENT 0.0 .IP \(bu 2 \fI\%https://docs.openstack.org/infra/manual/developers.html\fP .UNINDENT .SH WRITING A PATCH .sp We ask that all code submissions be \fI\%pep8\fP and \fI\%pyflakes\fP clean. The easiest way to do that is to run \fI\%tox\fP before submitting code for review in Gerrit. It will run \fBpep8\fP and \fBpyflakes\fP in the same manner as the automated test suite that will run on proposed patchsets. .sp When creating new YAML components, please observe the following style conventions: .INDENT 0.0 .IP \(bu 2 All YAML identifiers (including component names and arguments) should be lower\-case and multiple word identifiers should use hyphens. E.g., \(dqbuild\-trigger\(dq. .IP \(bu 2 The Python functions that implement components should have the same name as the YAML keyword, but should use underscores instead of hyphens. E.g., \(dqbuild_trigger\(dq. .UNINDENT .sp This consistency will help users avoid simple mistakes when writing YAML, as well as developers when matching YAML components to Python implementation. .SH UNIT TESTS .sp Unit tests have been included and are in the \fBtests\fP folder. Many unit tests samples are included as examples in our documentation to ensure that examples are kept current with existing behaviour. To run the unit tests, execute the command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C tox \-e py34,py27 .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 Note: View \fBtox.ini\fP to run tests on other versions of Python, generating the documentation and additionally for any special notes on running the test to validate documentation external URLs from behind proxies. .UNINDENT .SH INSTALLING WITHOUT SETUP.PY .sp For YAML support, you will need \fI\%libyaml\fP installed. .sp Mac OS X: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $ brew install libyaml .ft P .fi .UNINDENT .UNINDENT .sp Then install the required python packages using \fI\%pip\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $ sudo pip install PyYAML python\-jenkins .ft P .fi .UNINDENT .UNINDENT .SH QUICK START GUIDE .sp This guide was made with the impatient in mind so explanation is sparse. It will guide users through a set of typical use cases for JJB using the same job definitions we use to test JJB. .INDENT 0.0 .IP 1. 3 Clone the \fI\%repository\fP to get the JJB job definition \fI\%examples\fP .IP 2. 3 The \fI\%Installation\fP can be either from \fI\%pypi\fP (released version) or from the clone (master). .UNINDENT .sp Usage of the commands below assumes that you are at the root of the cloned directory. .SS Use Case 1: Test a job definition .sp JJB creates Jenkins XML configuration file from a YAML/JSON definition file and just uploads it to Jenkins. JJB provides a convenient \fBtest\fP command to allow you to validate the XML before you attempt to upload it to Jenkins. .sp Test a YAML job definition: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C jenkins\-jobs test tests/yamlparser/fixtures/templates002.yaml .ft P .fi .UNINDENT .UNINDENT .sp The above command prints the generated Jenkins XML to the console. If you prefer to send it to a directory: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C jenkins\-jobs test \-o output tests/yamlparser/fixtures/templates002.yaml .ft P .fi .UNINDENT .UNINDENT .sp The \fIoutput\fP directory will contain files with the XML configurations. .SS Use Case 2: Updating Jenkins Jobs .sp Once you\(aqve tested your job definition and are happy with it then you can use the \fBupdate\fP command to deploy the job to Jenkins. The \fBupdate\fP command requires a configuration file. An example file is supplied in the etc folder, you should update it to match your Jenkins master: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C jenkins\-jobs \-\-conf etc/jenkins_jobs.ini\-sample update tests/yamlparser/fixtures/templates002.yaml .ft P .fi .UNINDENT .UNINDENT .sp The above command will update your Jenkins master with the generated jobs. .sp \fBCaution\fP: JJB caches Jenkins job information locally. Changes made using the Jenkins UI will not update that cache, which may lead to confusion. See \fI\%Updating Jobs\fP for more information. .SS Use Case 3: Working with JSON job definitions .sp You can also define your jobs in json instead of yaml: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C jenkins\-jobs \-\-conf etc/jenkins_jobs.ini\-sample update tests/jsonparser/fixtures/simple.json .ft P .fi .UNINDENT .UNINDENT .sp The above command just uses a simple job definition. You can also convert any of the YAML examples to JSON and feed that to JJB. .SS Use Case 4: Deleting a job .sp To delete a job: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C jenkins\-jobs \-\-conf etc/jenkins_jobs.ini\-sample delete simple .ft P .fi .UNINDENT .UNINDENT .sp The above command deletes the job \fIsimple\fP from the Jenkins master. .SS Use Case 5: Providing plugins info .sp To generate a plugins info, using an account with Administrator rights: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C jenkins\-jobs get\-plugins\-info \-o plugins_info.yaml .ft P .fi .UNINDENT .UNINDENT .sp To run JJB update using the plugins_info.yaml: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C jenkins\-jobs update \-p plugins_info.yaml ./myjobs .ft P .fi .UNINDENT .UNINDENT .sp Please refer to the jenkins\-jobs \fI\%Command Reference\fP and the \fI\%Job Definitions\fP pages for more details. .SH INSTALLATION .sp To install Jenkins Job Builder from source, run: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pip install \-\-user jenkins\-job\-builder .ft P .fi .UNINDENT .UNINDENT .sp A virtual environment is recommended for development. For example, Jenkins Job Builder may be installed from the top level directory: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $ virtualenv .venv $ source .venv/bin/activate $ pip install \-r test\-requirements.txt \-e . .ft P .fi .UNINDENT .UNINDENT .sp Alternatively, the current release can be installed from pypi: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo pip install jenkins\-job\-builder .ft P .fi .UNINDENT .UNINDENT .sp The OpenStack project uses Puppet to manage its infrastructure systems, including Jenkins. If you use Puppet, you can use the \fI\%OpenStack Jenkins module\fP to install Jenkins Job Builder. .SS Documentation .sp Documentation is included in the \fBdoc\fP folder. To generate docs locally execute the command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C tox \-e docs .ft P .fi .UNINDENT .UNINDENT .sp The generated documentation is then available under \fBdoc/build/html/index.html\fP\&. .sp As over time URLs change or become stale there is also a testenv available to verify any links added. To run locally execute the command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C tox \-e docs\-linkcheck .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 Note: When behind a proxy it is necessary to use \fBTOX_TESTENV_PASSENV\fP to pass any proxy settings for this test to be able to check links are valid. .UNINDENT .SS Unit Tests .sp Unit tests have been included and are in the \fBtests\fP folder. We recently started including unit tests as examples in our documentation so to keep the examples up to date it is very important that we include unit tests for every module. To run the unit tests, execute the command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C tox \-e py27 .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 Note: View \fBtox.ini\fP to run tests on other versions of Python. .UNINDENT .SS Test Coverage .sp To measure test coverage, execute the command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C tox \-e cover .ft P .fi .UNINDENT .UNINDENT .SH CONFIGURATION FILE .sp After installation, you will need to create a configuration file. By default, \fBjenkins\-jobs\fP looks for \fB~/.config/jenkins_jobs/jenkins_jobs.ini\fP, \fB