17 Commits

Author SHA1 Message Date
Vsevolod Fedorov
60e8395c62 Add source location and context to error messages
Change-Id: I2e955c01b71a195bb6ff8ba2bb6f3a64cb3e1f58
2023-04-04 13:35:42 +03:00
Drew Welch
c1504e053f Fix: add support for fips-enabled systems using Python3.6 or greater.
FIPS restricts usage of md5 and requires the flag 'usedforsecurity' to be set False in order to avoid error:

ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS

Change-Id: I99a4ad0bf78bbeb898fb9dcfc79c03a14d596235
2022-03-09 23:03:31 +00:00
Thanh Ha
5a98ebb8bb
Fix flake8 BLK100 and BLK999 issues
Resolves flake8 BLK related issues.

"BLK100 Black would make changes."
"BLK999 Unexpected exception: ..."

Change-Id: Ic6d4265e3d02b2f2a15ab851eaed98288c62730c
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
2020-08-31 10:54:19 -04: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
Aigars Mahinovs
58c51178b3 Avoid extra XML elements in views
Non-view modules get called and add empty "actions", "builders" and
other XML elements to view XML tags where they are not supposed to be,
this causes Jenkins "Old data" warnings

Change-Id: Ie031192dca7ac0920e0953d533ed15c22db91022
Story: 2002159
Task: 20008
2018-08-13 12:39:58 +02:00
Daniel Watkins
df84460f7b Refactor duplicated code in xml_config.py
The view generation code was largely a copy/paste of the job generation
code.  This refactors that shared code in to a super-class that both
code paths can share.

(This has the side effect of improving the error message when an
incorrect project-type is specified; that improvement was previously
only applied to views.)

Change-Id: I1316162b885267c5e21793e59c2c3f7b95d5ce3b
2018-06-20 15:41:35 -04:00
Daniel Watkins
e6d6c276d1 Give an explicit error message when unsupported view type used
When specifying a view type that isn't supported by any modules (such as
"list-view" instead of "list"), this ensures that the user is guided
towards something correct.

This changes the error message in this case from:

AttributeError: 'NoneType' object has no attribute 'name'

to:

jenkins_jobs.errors.JenkinsJobsException: Unrecognized view type: list-view (supported types are: list, pipeline)

Change-Id: I0ee800db1c9c8aeecffcf11f1e86c03ba0590da8
2017-10-06 14:24:48 -04:00
Darragh Bailey
76c4441e8a Use standard python method naming for xml_config methods
Limit use of double underscore (or 'dunder') methods to python magic or
where it is an intention to avoid namespace collisions for classes
intended to be sub-classed.

An example were this would be applicable is a mixin class adding
memoisation to all methods would need to avoid namespace collisions
should it be added to a class intended to be sub-classed, and so for
any methods it uses to help manage the memoisation it should use
name-mangling to avoid them being accidentally overridden.

Change-Id: I0fe1e438687b23e2f0e1cef5229eef92e1a652ad
2016-11-14 12:07:21 +00:00
Thanh Ha
1deb3aff4c
Add view management functionality
- Adds the ability for JJB to work with views
- Views can be created, updated, and deleted.
- New modules for List view and Build Pipeline view are added
- New tests for testing the deletion of views

Example View configuration:

    - view:
        name: MyView
        view-type: list

Change-Id: Idb29a4407bcc14593e10a4d951036cb04e8e6c27
Co-Authored-By: Brandon Leonard <brandon.leonard@rackspace.com>
Co-Authored-By: Joao Vale <jpvale@gmail.com>
Co-Authored-By: Lucas Dutra Nunes <ldnunes@ossystems.com.br>
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
2016-10-14 09:14:21 -04:00
Darragh Bailey
a5bd11ed18 Raise exception on unrecognized project type
Change-Id: I3a9355333dfc7c3f51cd970d0c12deff24223e68
Story: 2000575
2016-09-14 18:02:16 +01:00
Wayne Warren
8ffb11a4bf Be explicit about objects exported by modules.
Change-Id: Iaea087c6c3a024922034423a8d56571184f33b7c
2016-08-20 00:34:35 -07:00
Wayne Warren
aaae83c623
Factor XmlJobGenerator out of YamlParser.
Separate XML generation from Yaml parsing/interpreting. The goal here
is to allow different sources to provide data for XML generation,
including external API users writing job definitions in pure Python or
JJB developers who would like to work on alternative Yaml parsing code
since the current YamlParser has very likely reached the limits of
what can be reasonably done with one giant expandYaml procedure.

Change-Id: I9da848acac7e944c0e07286b7399b2e1956a58a5
2016-08-18 22:42:24 -04:00
Wayne Warren
5dee372560 Remove Python 2.6 compatibility patch.
Since we don't test or claim to support Python 2.6, remove this patch.

Change-Id: Ic1c20dd290393a6a7723d5b97302cbc3707c7659
2016-01-08 15:54:30 +00:00
Darragh Bailey
c012f81b79 Remove deprecated getChildren() usage
Use of the getChildren() method is deprecated in favour of simply
iterating over an element.

Change-Id: Ica245ffbd5544df6b171d356aba1df61cdd2d999
2015-11-10 18:32:19 +00:00
Darragh Bailey
e5738d0852 Allow whitespace to be significant
Remove the test options suppressing ignoring differences in whitespace
outputted in the XML to allow capturing of issues where the code
incorrectly adds or removes significant whitespace.

Add a helper function to deal with the edge case of parsing XML directly
that contains non significant whitespace to avoid accidentally adding
excess whitespace when minidom outputs the resulting document.

Change-Id: I9936042cd82c204ba2b3c19f575703e33564f7fd
2015-08-11 18:31:48 +01:00
Darragh Bailey
571a0efd16 Move writexml fix for older minidom to same module as caller
With the reorganization of code to move the XmlJob class to a separate
file, the patch to modify the minidom method writexml for earlier
instances that incorrectly added whitespace should be relocated to be
alongside.

This ensures the patch exists along with the code that is using
minidom's functionality.

Change-Id: I6ed3267c3c076dc5f8d40f0c97706c33e4018261
2015-05-05 14:32:21 +01:00
Wayne
4a8b93b8c2 Remove YamlParser from jenkins_jobs.builder
The goal of this patch is simply to move some classes out of
jenkins_jobs.builder into more appropriately-named modules. This started with
simply moving YamlParser into jenkins_jobs.parser but led to other moves in
order to avoid cyclic imports since YamlParser uses other classes previously
defined in jenkins_jobs.builder.

That said, this patch doesn't intend to address all of the clutter in
jenkins_jobs.builder, mostly just what is necessary to get started working on
YamlParser independent of other classes in that module.

Change-Id: Ie88bf683e495033eb0b670fe29c256a70282735f
2015-04-22 11:59:07 -07:00