Commit Graph

91 Commits

Author SHA1 Message Date
Vsevolod Fedorov a1d4f91d1a Add context for macro calls
Change-Id: I674b153770297c3a0abbfcee26d840e0f2be490b
2023-11-22 12:58:37 +03:00
Vsevolod Fedorov af9e03ec08 Rewrite YAML parser
Rewrite YAML parser, YAML objects and parameters expansion logic to
enable better control over expansion logic.
Broken backward compatilibity:
* More agressive parameter expansion. This may lead to parameters
  expanded in places where they were not expanded before.
* Top-level elements, which is not known to parser (such as 'job',
  'view', 'project' etc), are now lead to parse failures.
  Prepend them with underscore to be ignored by parser.
* Files included using '!include-raw:' elements and having formatting in
  it's path ('lazy-loaded' in previous implementation) are now expanded
  too.
  Use '!include-raw-escape:' for them instead.
  See changes in these tests for examples:
    tests/yamlparser/job_fixtures/lazy-load-jobs-multi001.yaml
    tests/yamlparser/job_fixtures/lazy-load-jobs-multi002.yaml
    tests/yamlparser/job_fixtures/lazy-load-jobs001.yaml
* Parameters with template value using itself were substituted as is.
  For example: "timer: '{timer}'" was expanded to "{timer}". Now it
  leads to recursive parameter error.
  See changes in this test for example:
    tests/yamlparser/job_fixtures/parameter_name_reuse_default.*
    ->
    tests/yamlparser/error_fixtures/parameter_name_reuse_default.*
* When job group includes a job which was never declared, it was just
  ignored. Now it fails: job is missing.
  See changes in this test for example:
    tests/yamlparser/job_fixtures/job_group_includes_missing_job.*
    ->
    tests/yamlparser/error_fixtures/job_group_includes_missing_job.*

Change-Id: Ief4e515f065a1b9e0f74fe06d7e94fa77d69f273
2023-02-28 20:16:57 +03:00
Vsevolod Fedorov 6b92807cd7 Tests: Rename yamlparser tests and fixture directories
Rename fixtures directory to job_fixtures to prepare for adding view_fixtures
directory in the following commits.

Change-Id: Ic20997cae020b542ddc22bf444fa6b92fbcae064
2023-01-26 11:06:23 +03:00
Zuul 6f402e76b8 Merge "Fix uno-choice parameter macro processing" 2022-03-18 20:14:35 +00:00
wangdonghui 50f7b49f64 Add support for Persistent Parameter
Change-Id: I947f85cb8ce85bf44b695fc45b8d56b4bee852a1
2022-02-14 16:08:53 +08:00
Artem Nikitin 289b5c55ad Fix uno-choice parameter macro processing
Jinja2 formatter wasn't applied in case of macro parameter
without arguments, due to `ModuleRegistry.dispatch`
couldn't find the parameter definition in the registry.

On other hand, project properties weren't applied for
uno-choice parameter macro with arguments, so it makes
impossible to use these parameters with macros.

Change-Id: Idaff9307dff30567a80b917f6e5ac0717100c349
2022-02-14 07:10:25 +00:00
Pat Long d352ed9656 Fix documentation links
Jenkins Wiki has been fully taken off line, so update the remaining
links to reference either the relevant plugin page or the github repo.

Add extlink target for repo in jenkinsci github org.

The sonatype-clm plugin seems to be more-or-less completely deprecated,
so update the description to indicate this and link to the
nexus-artifact-uploader plugin.

Update the jjb sphinx plugin so that it generates references for the
yamlfunctions.

Change-Id: If2241e751d01a60a8cb4cbaea5b3176aeb92eab4
Signed-off-by: Pat Long <pllong@arista.com>
2021-09-09 18:34:40 -04:00
Artem Nikitin 7f803887ee Fix uno-choice pluggin parameter macro usage
If the parameter is used in a macro, special fields from the
job layer (`_project-name`, `_project-full-name`) were not initialized.

Change-Id: Ie70f592c8ee71c3b8e1cfc3c2ba578e814af0a29
2021-07-12 10:47:14 +03:00
Ruslan Marinin 15a0896791 fixed broken active choice reactive param after job creation
Change-Id: I7e7362a73e9478bdbd445f5178f982afa346f58a
2021-04-29 20:24:20 +03:00
Igor Lakhtenkov f810d8bc30 Added support of Active Choice Reactive Parameter
Change-Id: I25e926603682db543658aad82efb6eb41d1b5cb4
Task: #42221
2021-04-07 01:33:01 +03:00
Igor Lakhtenkov 2e988b3f26 Added support of json type for extended choice parameter and related parameters.
Added support of multilevel type for extended choice parameter
dded jenkins_jobs.modules.helpers.check_mutual_exclusive_data_args decorator that used for validating data arguments
in jenkins_jobs.modules.parameters.extended_choice_param method.

Change-Id: Id8c0f8090dd99022501558cafa5b1c27e6675425
Task: #41320
2021-01-04 12:36:24 +03:00
Eren ATAS 6cad52986e Active Choices parameters support
Following parameters have been implemented in JJB:
- Active Choices Parameter
- Active Choices Reactive Reference Parameter

Test cases also have been written.

Change-Id: I6e953aa26114fde9ff293ed17cc17d5972df9af3
Signed-off-by: Eren ATAS <eatas.contractor@libertyglobal.com>
2020-10-12 14:00:54 +02:00
Eren ATAS e4f2724a00 [ONEM-16360] Parameter Separator support
Tests are also added.

Change-Id: I509fd9689be7693f95f87a5f23c2fe5adf2f82d5
Signed-off-by: Eren ATAS <eatas.contractor@libertyglobal.com>
2020-09-25 14:55:43 +00:00
Igor Lakhtenkov 2eb74a15cd Added trim option for String parameter.
Task: #22637
Change-Id: Ic2722aac586d3911e3ff5ab4c2d3c5a7a03fa14e
2020-05-22 17:04:49 +03:00
Thanh Ha c3ef26c1b0
Ignore py:obj warnings and fail on warnings
* Enables fail on warnings and enable nitpicky
* Consolidate string -> str for args

Change-Id: Id5c29d48813fd6f772816dc74c7c4e408097113d
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
2020-01-22 20:43:52 -05:00
Thanh Ha 4424ab24c2
Update Jenkins wiki -> plugins URLs parameters
The Jenkins Wiki page is deprecated and Jenkins community is expected
to migrate their documentation to plugins.jenkins.io URL. This patch
updates all parameters that have a relevant plugins.jenkins.io URL
documentation link.

Change-Id: I3f944d268031c0217544ee94bb5361276ca9158d
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
2020-01-22 18:47:43 -05:00
Thanh Ha 7b00932d2c
Enable docs-linkcheck
This toxenv will allow us to flag URLs that no longer work. We
also switch from using old style setup.py build_sphinx to the
newer sphinx-build command.

Change-Id: I62f42918814fb6eea4876e0d22c6bccddf86a826
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
2020-01-06 09:50:13 -05:00
Thanh Ha 4d90c187a9 Auto-generated output from python-black
Please review the following patch containing the code changes in
the repo. This patch is a transition patch and is the auto-generated
output of the python-black tool.

Change-Id: I2d2de71da8a105fb62b561899ae78441ddab4032
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
2019-09-09 19:23:24 +01:00
Gleb Samsonov fc7864ab7f
adding variable bindings option to extended parameters
Change-Id: I4e9fba2da7771d1cac04bcb9818389207a6f301e
2019-04-09 09:41:28 +08:00
Thanh Ha 02e85408f0
Fix default '0' being ignored
The problem with `if default:` is that it evaluates int 0 to be
equivalent to False. If a user is passing in a int 0 then they
should be expected to receive int 0 in the case of defaults.

Change-Id: Ida1f4c68b6f9d1af5b98d633b552f038c57654cc
Signed-off-by: Thanh Ha <zxiiro@linux.com>
2018-12-05 17:59:12 +08:00
Thanh Ha b06b5f2239
Convert parameter default value to str
This resolves the error "TypeError: cannot serialize 1 (type int)" when
using a parameter inside of a macro and then passing an integer value
to the macro. For example:

    - parameter:
        name: int-param
        parameters:
          - string:
              name: VAR_INT
              default: '{var}'

    - job-template:
        name: int-param
        parameters:
          - int-param:
              var: 1

Change-Id: Ie3a5d2e03b7aa0b7cafdb467cd0118e4ff6e73bc
Signed-off-by: Thanh Ha <zxiiro@linux.com>
2018-11-29 05:41:56 +08:00
Bernhard M. Wiedemann 405df97718 Use upstream default for allNodesMatchingLabel
As has been found earlier in Idf3460f165209611113193c7e85a884c42511371
having allNodesMatchingLabel on is a very bad idea
because it kills scaling in your CI
by scheduling every job on every node in parallel

Change-Id: Iae07b578ccfb6f728a1615628479318c46e0530a
2018-09-07 13:17:16 +02:00
Aigars Mahinovs 07a059d270 Allow running only on one of nodes with label parameter
Current default value setting makes the jobs with label parameter
execute in parallel on all nodes matching a label. In some cases that is
not expected and is undesirable. It is also no the default value
upstream

Change-Id: Idf3460f165209611113193c7e85a884c42511371
2018-08-21 10:06:51 +02:00
tanhengyeow 784d000d4b
Refactor parameters.py
Converted all relevant functions to use helpers.<insert function>
instead of a specific import.

Added commas to last entries of mapping tuples.

Signed-off-by: Tan Heng Yeow <E0032242@u.nus.edu>
Change-Id: Ie7c40809ad8259fc3906871360c16dbb6e58a4b0
2018-07-23 23:13:44 -04:00
Zuul fab15b1238 Merge "Add groovy-script-file option to extended parameters" 2018-06-21 17:35:14 +00:00
Zuul aa70c3621c Merge "Improve support for nodelabelparameter" 2018-06-21 17:30:06 +00:00
tanhengyeow 3308fd53bb Improve support for nodelabelparameter
Adds support for all fields for nodelabelparameter. Uploaded new tests, including one that covers existing behavior to prevent regression.

Story: #2001287
Task: #5835

Change-Id: I9dc4574427626fd56ba41149f0f6ab131a22e966
2018-06-21 22:05:32 +08:00
Sorin Sbarnea 4f7b6ee568
upgrade hacking module
- upgrades hacking to current version
- sorts new linting issues
- sorts bug with sys.reload on py3

Change-Id: I4a18abc93116667a2733e8aec619ac59ea73d630
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2018-06-19 18:04:37 +01:00
Yaron de Leeuw ba94e2ad72 Add groovy-script-file option to extended parameters
The extended parameters plugin allows to specify where the groovy script
file is to generate parameter

Change-Id: I0c6ac0b49c24b8d3afbc06b003847de2e043c2b8
2018-05-24 12:55:08 -04:00
tanhengyeow f37444423b Improve support for Extended Choice Parameters
Adds support for extended choice parameters with regards to default groovy scripts.

Change-Id: I9d2a61013f041e7b81a80b5618781dbefeace329
Story: #2001931
Task: #14461
2018-05-22 17:23:21 +00:00
Trevor Bramwell 2507f60a4e Fix Parameter: Credentials Plugin docs example
Due to an extra colon and indentation, the example for the credentials
plugin parameter was not being included correctly.

Change-Id: I7363f8dea713410dc4fa263a557ba7cb6d1c4e58
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
2018-04-16 22:19:19 -07:00
Luca Pierri 3264b244b5 fix spelling errors
Change-Id: I42b6bb46a9e5574f88ec5c0cb5726a65353a4fd7
2018-04-16 23:57:41 +02:00
Yolande Amate 1cbe42eb9d Update dynamic_scriptler_param_common to use convert_xml()
Change-Id: Ia73458e7f55de5c8c2213040bfab57299b7aa0eb
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2018-02-27 18:19:40 +00:00
Zuul 673523e2c3 Merge "Enable groovy-script includes for extended_choice_param" 2018-02-27 17:48:01 +00:00
Sorin Sbarnea d8ace6802d docs: sphinx upgrade and warnings as erros
Change-Id: I455ac0d79cca3883d3a758a2709c8c0255f4cc7d
2018-01-26 23:57:53 +00:00
Thomas Meeus ab9d80cc79
Enable groovy-script includes for extended_choice_param
Change-Id: I3e0f4dec04d20b1603774a483b2776caa8504b9c
2017-12-06 15:30:16 +01:00
Vasily Gorin d77b4d67f9 Fix git-parameter sortMode values
It is impossible now to chose one of the following values of sortMode:
[ASCENDING_SMART, DESCENDING_SMART] because default value in JJB was hardcoded w/o '_',
but jenkins expect value w/ '_'. So if we pass e.g. ACENDING SMART (w/o '_') we get
improperly configured job and sortMode in this way replaced with NONE.
If we pass w/ '_' we got an error on testing JJB definitions.

Please merge ASAP.

Change-Id: I9bc4ff471ddb7d648005832e055ba14d59822489
2017-11-27 14:10:24 +03:00
Zuul f668bbae49 Merge "Update svn-tag parameter to support all config" 2017-10-27 03:41:38 +00:00
mostwanted b972fc07ec
Add support for the Git Parameter Jenkins plugin
Change-Id: I7522f1250de88f073c0f47149dafed7fff9ecd9f
Resolves: #2000902, #2000802
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
2017-10-25 23:32:50 -04:00
Joost van der Griendt 208527640a
Update svn-tag parameter to support all config
Additionally update the plugin to use convert_mapping_to_xml and add
min/max tests.

Change-Id: I8f0a9054c12ea984a286aea1012513baac07479f
Co-Authored-By: Thanh Ha <thanh.ha@linuxfoundation.org>
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
2017-10-25 22:52:39 -04:00
Zuul 6445c6c3a1 Merge "Update extended_choice_param to use convert_xml()" 2017-10-23 17:24:35 +00:00
Yolande Amate 00e2ea35d6 Update extended_choice_param to use convert_xml()
Change-Id: Ia713a21061d6d6db1d1ac48983a44f6f3ea1cc1d
2017-08-05 02:27:49 +01:00
Jenkins ed90a0cf0c Merge "Update matrix_combinations_param to use convert_xml()" 2017-07-10 05:16:10 +00:00
Yolande Amate 297a91c445 Update matrix_combinations_param to use convert_xml()
Change-Id: I1f26a131017af896ee0afe3c45fad0502ff14069
2017-07-02 17:55:39 +01:00
Jenkins 9d4259bef8 Merge "Update copyartifact_build_selector_param to use convert_to_xml()" 2017-06-27 16:34:20 +00:00
Jenkins 0cf0afa4e9 Merge "Update svn_tags_param to use convert_mapping_to_xml()" 2017-06-27 16:34:14 +00:00
Jenkins 1fe3a24acf Merge "Update run_param to make use of convert_mapping_to_xml()" 2017-06-27 14:34:47 +00:00
Jenkins fd8cae10cc Merge "Update validating_string_param to make use of convert_mapping_to_xml()" 2017-06-27 14:34:43 +00:00
Yolande Amate 43bd517465 Update copyartifact_build_selector_param to use convert_to_xml()
Change-Id: I8423b67349cbff5de3fa68f3282bdb7a025baf3d
2017-06-23 18:27:31 +01:00
Yolande Amate fa072dc753 Update svn_tags_param to use convert_mapping_to_xml()
Change-Id: Ibcd7e1a2b4ea8d1530043d9bb0646643e5ed7bdd
2017-06-23 04:00:10 +01:00