diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index fc3677581..dd3c713dc 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -45,13 +45,14 @@ def builds_chain_fingerprinter(parser, xml_parent, data): `. :arg bool per-builds-chain: enable builds hierarchy fingerprinting - (default False) + (default false) :arg bool per-job-chain: enable jobs hierarchy fingerprinting - (default False) + (default false) Example: .. literalinclude:: /../../tests/properties/fixtures/fingerprinter.yaml + :language: yaml """ fingerprinter = XML.SubElement(xml_parent, 'org.jenkinsci.plugins.' @@ -75,11 +76,11 @@ def ownership(parser, xml_parent, data): Example: .. literalinclude:: /../../tests/properties/fixtures/ownership.yaml + :language: yaml """ - ownership_plugin = \ - XML.SubElement(xml_parent, - 'com.synopsys.arc.' - 'jenkins.plugins.ownership.jobs.JobOwnerJobProperty') + ownership_plugin = XML.SubElement( + xml_parent, + 'com.synopsys.arc.jenkins.plugins.ownership.jobs.JobOwnerJobProperty') ownership = XML.SubElement(ownership_plugin, 'ownership') owner = str(data.get('enabled', True)).lower() XML.SubElement(ownership, 'ownershipEnabled').text = owner @@ -100,15 +101,12 @@ def promoted_build(parser, xml_parent, data): Requires the Jenkins :jenkins-wiki:`Promoted Builds Plugin `. - :arg list names: the promoted build names + :arg list names: the promoted build names (optional) - Example:: + Example: - properties: - - promoted-build: - names: - - "Release to QA" - - "Jane Must Approve" + .. literalinclude:: /../../tests/properties/fixtures/promoted_build.yaml + :language: yaml """ promoted = XML.SubElement(xml_parent, 'hudson.plugins.promoted__builds.' 'JobPropertyImpl') @@ -123,13 +121,12 @@ def github(parser, xml_parent, data): """yaml: github Sets the GitHub URL for the project. - :arg str url: the GitHub URL + :arg str url: the GitHub URL (required) - Example:: + Example: - properties: - - github: - url: https://github.com/openstack-infra/jenkins-job-builder/ + .. literalinclude:: /../../tests/properties/fixtures/github.yaml + :language: yaml """ github = XML.SubElement(xml_parent, 'com.coravy.hudson.plugins.github.' @@ -143,11 +140,12 @@ def least_load(parser, xml_parent, data): Enables the Least Load Plugin. Requires the Jenkins :jenkins-wiki:`Least Load Plugin `. - :arg bool disabled: whether or not leastload is disabled (default True) + :arg bool disabled: whether or not leastload is disabled (default true) Example: .. literalinclude:: /../../tests/properties/fixtures/least-load002.yaml + :language: yaml """ least = XML.SubElement(xml_parent, 'org.bstick12.jenkinsci.plugins.leastload.' @@ -165,19 +163,14 @@ def throttle(parser, xml_parent, data): :arg int max-per-node: max concurrent builds per node (default 0) :arg int max-total: max concurrent builds (default 0) - :arg bool enabled: whether throttling is enabled (default True) + :arg bool enabled: whether throttling is enabled (default true) :arg str option: throttle `project` or `category` :arg list categories: multiproject throttle categories - Example:: - - properties: - - throttle: - max-total: 4 - categories: - - cat1 - - cat2 + Example: + .. literalinclude:: /../../tests/properties/fixtures/throttle001.yaml + :language: yaml """ throttle = XML.SubElement(xml_parent, 'hudson.plugins.throttleconcurrents.' @@ -215,6 +208,7 @@ def sidebar(parser, xml_parent, data): Example: .. literalinclude:: /../../tests/properties/fixtures/sidebar02.yaml + :language: yaml """ sidebar = xml_parent.find('hudson.plugins.sidebar__link.ProjectLinks') if sidebar is None: @@ -284,58 +278,49 @@ def authenticated_build(parser, xml_parent, data): Specifies an authorization matrix where only authenticated users may trigger a build. - DEPRECATED + .. deprecated:: 0.1.0. Please use :ref:`authorization `. - Example:: + Example: + + .. literalinclude:: + /../../tests/properties/fixtures/authenticated_build.yaml + :language: yaml - properties: - - authenticated-build """ # TODO: generalize this - if data: - security = XML.SubElement(xml_parent, - 'hudson.security.' - 'AuthorizationMatrixProperty') - XML.SubElement(security, 'permission').text = \ - 'hudson.model.Item.Build:authenticated' + security = XML.SubElement(xml_parent, + 'hudson.security.' + 'AuthorizationMatrixProperty') + XML.SubElement(security, 'permission').text = ( + 'hudson.model.Item.Build:authenticated') def authorization(parser, xml_parent, data): """yaml: authorization Specifies an authorization matrix - The available rights are: - job-delete - job-configure - job-read - job-extended-read - job-discover - job-build - job-workspace - job-cancel - run-delete - run-update - scm-tag + :arg list : `` is the name of the group or user, containing + the list of rights to grant. - Example:: + : rights: + * **job-delete** + * **job-configure** + * **job-read** + * **job-extended-read** + * **job-discover** + * **job-build** + * **job-workspace** + * **job-cancel** + * **run-delete** + * **run-update** + * **scm-tag** + + Example: + + .. literalinclude:: + /../../tests/properties/fixtures/authorization_matrix.yaml + :language: yaml - properties: - - authorization: - admin: - - job-delete - - job-configure - - job-read - - job-discover - - job-build - - job-workspace - - job-cancel - - run-delete - - run-update - - scm-tag - anonymous: - - job-discover - - job-read - - job-extended-read """ mapping = { @@ -388,11 +373,10 @@ def priority_sorter(parser, xml_parent, data): :arg int priority: Priority of the job. Higher value means higher priority, with 100 as the standard priority. (required) - Example:: + Example: - properties: - - priority-sorter: - priority: 150 + .. literalinclude:: /../../tests/properties/fixtures/priority_sorter.yaml + :language: yaml """ priority_sorter_tag = XML.SubElement(xml_parent, 'hudson.queueSorter.' @@ -410,22 +394,19 @@ def build_blocker(parser, xml_parent, data): Requires the Jenkins :jenkins-wiki:`Build Blocker Plugin `. - :arg bool use-build-blocker: Enable or disable build blocker - (default true) - :arg list blocking-jobs: One regular expression per line - to select blocking jobs by their names. (required) - + :arg bool use-build-blocker: Enable or disable build blocker (default true) + :arg list blocking-jobs: One regular expression per line to select + blocking jobs by their names. (required) :arg str block-level: block build globally ('GLOBAL') or per node ('NODE') (default 'GLOBAL') - :arg str queue-scanning: scan build queue for all builds ('ALL') or only buildable builds ('BUILDABLE') (default 'DISABLED')) - Example: - .. literalinclude:: \ - /../../tests/properties/fixtures/build-blocker01.yaml + .. literalinclude:: + /../../tests/properties/fixtures/build-blocker01.yaml + :language: yaml """ blocker = XML.SubElement(xml_parent, 'hudson.plugins.' @@ -466,14 +447,14 @@ def copyartifact(parser, xml_parent, data): Requires the Jenkins :jenkins-wiki:`Copy Artifact plugin `. - :arg string projects: comma separated list of projects that can copy + :arg str projects: comma separated list of projects that can copy artifacts of this project. Wild card character '*' is available. - Example: - .. literalinclude:: \ - /../../tests/properties/fixtures/copyartifact.yaml + .. literalinclude:: + /../../tests/properties/fixtures/copyartifact.yaml + :language: yaml """ copyartifact = XML.SubElement(xml_parent, @@ -503,12 +484,14 @@ def batch_tasks(parser, xml_parent, data): :arg list batch-tasks: Batch tasks. - :Task: * **name** (`str`) Task name. - * **script** (`str`) Task script. + :Tasks: + * **name** (`str`) Task name. + * **script** (`str`) Task script. Example: .. literalinclude:: /../../tests/properties/fixtures/batch-task.yaml + :language: yaml """ pdef = XML.SubElement(xml_parent, @@ -531,10 +514,10 @@ def heavy_job(parser, xml_parent, data): :arg int weight: Specify the total number of executors that this job should occupy (default 1) - Example: .. literalinclude:: /../../tests/properties/fixtures/heavy-job.yaml + :language: yaml """ heavyjob = XML.SubElement(xml_parent, @@ -553,15 +536,16 @@ def slave_utilization(parser, xml_parent, data): `. :arg int slave-percentage: Specify the percentage of a slave's execution - slots that this job should occupy (default: 0) + slots that this job should occupy (default 0) :arg bool single-instance-per-slave: Control whether concurrent instances of this job will be permitted to run in parallel on a single slave - (default: False) + (default false) Example: - .. literalinclude:: \ - /../../tests/properties/fixtures/slave-utilization1.yaml + .. literalinclude:: + /../../tests/properties/fixtures/slave-utilization1.yaml + :language: yaml """ utilization = XML.SubElement( xml_parent, 'com.suryagaddipati.jenkins.SlaveUtilizationProperty') @@ -579,15 +563,16 @@ def delivery_pipeline(parser, xml_parent, data): Requires the Jenkins :jenkins-wiki:`Delivery Pipeline Plugin `. + :arg str stage: Name of the stage for this job (default '') + :arg str task: Name of the task for this job (default '') :arg str description: task description template for this job - (default: '') - :arg str stage: Name of the stage for this job (default: '') - :arg str task: Name of the task for this job (default: '') + (default '') Example: - .. literalinclude:: \ - /../../tests/properties/fixtures/delivery-pipeline1.yaml + .. literalinclude:: + /../../tests/properties/fixtures/delivery-pipeline1.yaml + :language: yaml """ pipeline = XML.SubElement(xml_parent, @@ -609,8 +594,9 @@ def zeromq_event(parser, xml_parent, data): Example: - .. literalinclude:: \ - /../../tests/properties/fixtures/zeromq-event.yaml + .. literalinclude:: + /../../tests/properties/fixtures/zeromq-event.yaml + :language: yaml """ @@ -626,14 +612,15 @@ def rebuild(parser, xml_parent, data): `. :arg bool auto-rebuild: Rebuild without asking for parameters - (default: False) + (default false) :arg bool rebuild-disabled: Disable rebuilding for this job - (default: False) + (default false) Example: - .. literalinclude:: \ - /../../tests/properties/fixtures/rebuild.yaml + .. literalinclude:: + /../../tests/properties/fixtures/rebuild.yaml + :language: yaml """ sub_element = XML.SubElement(xml_parent, 'com.sonyericsson.rebuild.RebuildSettings') diff --git a/tests/properties/fixtures/authenticated_build.xml b/tests/properties/fixtures/authenticated_build.xml new file mode 100644 index 000000000..27b396c38 --- /dev/null +++ b/tests/properties/fixtures/authenticated_build.xml @@ -0,0 +1,8 @@ + + + + + hudson.model.Item.Build:authenticated + + + diff --git a/tests/properties/fixtures/authenticated_build.yaml b/tests/properties/fixtures/authenticated_build.yaml new file mode 100644 index 000000000..6bdd5e0bb --- /dev/null +++ b/tests/properties/fixtures/authenticated_build.yaml @@ -0,0 +1,2 @@ +properties: + - authenticated-build diff --git a/tests/properties/fixtures/authorization_matrix.xml b/tests/properties/fixtures/authorization_matrix.xml new file mode 100644 index 000000000..bdad6d26d --- /dev/null +++ b/tests/properties/fixtures/authorization_matrix.xml @@ -0,0 +1,20 @@ + + + + + hudson.model.Item.Delete:admin + hudson.model.Item.Configure:admin + hudson.model.Item.Read:admin + hudson.model.Item.Discover:admin + hudson.model.Item.Build:admin + hudson.model.Item.Workspace:admin + hudson.model.Item.Cancel:admin + hudson.model.Run.Delete:admin + hudson.model.Run.Update:admin + hudson.scm.SCM.Tag:admin + hudson.model.Item.Discover:anonymous + hudson.model.Item.Read:anonymous + hudson.model.Item.ExtendedRead:anonymous + + + diff --git a/tests/properties/fixtures/authorization_matrix.yaml b/tests/properties/fixtures/authorization_matrix.yaml new file mode 100644 index 000000000..7863e3b60 --- /dev/null +++ b/tests/properties/fixtures/authorization_matrix.yaml @@ -0,0 +1,17 @@ +properties: + - authorization: + admin: + - job-delete + - job-configure + - job-read + - job-discover + - job-build + - job-workspace + - job-cancel + - run-delete + - run-update + - scm-tag + anonymous: + - job-discover + - job-read + - job-extended-read diff --git a/tests/properties/fixtures/github.xml b/tests/properties/fixtures/github.xml new file mode 100644 index 000000000..08413fe37 --- /dev/null +++ b/tests/properties/fixtures/github.xml @@ -0,0 +1,8 @@ + + + + + https://github.com/openstack-infra/jenkins-job-builder/ + + + diff --git a/tests/properties/fixtures/github.yaml b/tests/properties/fixtures/github.yaml new file mode 100644 index 000000000..8aceba64e --- /dev/null +++ b/tests/properties/fixtures/github.yaml @@ -0,0 +1,3 @@ +properties: + - github: + url: https://github.com/openstack-infra/jenkins-job-builder/ diff --git a/tests/properties/fixtures/priority_sorter.xml b/tests/properties/fixtures/priority_sorter.xml new file mode 100644 index 000000000..569969acc --- /dev/null +++ b/tests/properties/fixtures/priority_sorter.xml @@ -0,0 +1,8 @@ + + + + + 150 + + + diff --git a/tests/properties/fixtures/priority_sorter.yaml b/tests/properties/fixtures/priority_sorter.yaml new file mode 100644 index 000000000..53eb88465 --- /dev/null +++ b/tests/properties/fixtures/priority_sorter.yaml @@ -0,0 +1,3 @@ +properties: + - priority-sorter: + priority: 150 diff --git a/tests/properties/fixtures/promoted_build.xml b/tests/properties/fixtures/promoted_build.xml new file mode 100644 index 000000000..035c08d5e --- /dev/null +++ b/tests/properties/fixtures/promoted_build.xml @@ -0,0 +1,11 @@ + + + + + + Release to QA + Jane Must Approve + + + + diff --git a/tests/properties/fixtures/promoted_build.yaml b/tests/properties/fixtures/promoted_build.yaml new file mode 100644 index 000000000..2cf571167 --- /dev/null +++ b/tests/properties/fixtures/promoted_build.yaml @@ -0,0 +1,5 @@ +properties: + - promoted-build: + names: + - "Release to QA" + - "Jane Must Approve" diff --git a/tests/properties/fixtures/throttle001.xml b/tests/properties/fixtures/throttle001.xml index 073a9f8fb..2c9357a65 100644 --- a/tests/properties/fixtures/throttle001.xml +++ b/tests/properties/fixtures/throttle001.xml @@ -2,14 +2,14 @@ - 0 + 2 4 true cat1 cat2 - + category 1 diff --git a/tests/properties/fixtures/throttle001.yaml b/tests/properties/fixtures/throttle001.yaml index 1fb6a063f..b7e04aa53 100644 --- a/tests/properties/fixtures/throttle001.yaml +++ b/tests/properties/fixtures/throttle001.yaml @@ -1,6 +1,8 @@ properties: - throttle: + max-per-node: 2 max-total: 4 categories: - cat1 - cat2 + option: category diff --git a/tests/properties/fixtures/throttle002.xml b/tests/properties/fixtures/throttle002.xml new file mode 100644 index 000000000..7e3d0a378 --- /dev/null +++ b/tests/properties/fixtures/throttle002.xml @@ -0,0 +1,16 @@ + + + + + 0 + 0 + true + + cat1 + cat2 + + project + 1 + + + diff --git a/tests/properties/fixtures/throttle002.yaml b/tests/properties/fixtures/throttle002.yaml new file mode 100644 index 000000000..cd9b36d0a --- /dev/null +++ b/tests/properties/fixtures/throttle002.yaml @@ -0,0 +1,6 @@ +properties: + - throttle: + categories: + - cat1 + - cat2 + option: project