Commit Graph

316 Commits

Author SHA1 Message Date
Christian Henz 6b757a7c36 Do not initialize Request headers with bytestring.
Closes-Bug: 1781381
Change-Id: I14fcf165988bfe5fadf680d31152327eccbab5f5
2023-11-28 22:34:36 +01:00
Christoph Erhardt 876a2a928c Fix compatibility with setuptools >= 66
The Python world, including the `setuptools` package, has migrated to
the versioning scheme defined in PEP 440. Unfortunately, the versioning
of Jenkins plugins is less strict than that. As a consequence,
`pkg_resources.parse_version()` now rejects versions as invalid.

Fix `PluginVersion` by salvaging the implementation of the old
`LegacyVersion` class, which used to be part of the `packaging` library
prior to version 22.0. The code is licensed under a 2-clause BSD
licence.

For compatibility with older Python versions, remove type annotations
from the copied code.

Change-Id: Iaa057dcd81620fed861cb11bed534ff7f9ab3f32
Signed-off-by: Christoph Erhardt <ce+ubuntuone@sicherha.de>
2023-10-19 15:42:27 +00:00
Guillaume DeMengin 5c44d7c9ec get_build_artifact_as_bytes to support non-json files
new function get_build_artifact_as_bytes to replace get_build_artifact (incompatible with artifacts not json-formatted)
+ use a stream to download binary artifacts

all artifacts are returned as bytes to avoid encoding issues
and an exception NotFoundException is raised in case of missing artifact

Closes-Bug: #1973243
Change-Id: I24ce4ecd854f8a19ed4d760404adb7d1ac6b5509
2023-10-14 14:52:56 +00:00
Vsevolod Fedorov a8f0d8cfda STORY 2010790: Handle 'all' view name when requested 'All'
Jenkins version 2.387.1 or earlier can return 'all' as view name
when requested is 'All'. Add workaround for that.

Change-Id: I6b5327a5f969607ca4838a13bbac838f44e76ccb
2023-08-19 10:06:25 +00:00
Kenyon Ralph 5a98031aee WrappedSession: Fix URL to requests issue 3829
The repo moved on GitHub and the old URL returns error 404.

Change-Id: Ida67cdfad02accc917fcd4646cc1efaff01bcc5f
2023-08-03 11:30:10 -07:00
Guillaume DeMengin e1a086ad45 CI: add support to python 37 to 311
Change-Id: I48c411f9283fb941ba81181265f59974af649a46
2023-07-17 14:17:35 +00:00
Zuul 6a3dc81819 Merge "Use multiprocess to avoid pickle errors in tox on macos" 2023-07-17 14:16:35 +00:00
Ken Dreyer ba9f06e0c2 support urllib3 newer DEFAULT_TIMEOUT
urllib3 1.x used to accept socket._GLOBAL_DEFAULT_TIMEOUT as a sentinal
object to mean "no configured timeout".

In urllib3 2.x, urllib3 uses its own _DEFAULT_TIMEOUT sentinal object,
and it rejects socket._GLOBAL_DEFAULT_TIMEOUT.

Assign our own DEFAULT_TIMEOUT constant to the newer object if it
exists, and fall back to the old behavior on old urllib3 versions.

Co-authored-by: Vsevolod Fedorov <vsevolod.fedorov@gmail.com>
Closes-Bug: #2018567
Change-Id: Ic626ba0e8ed79eec3a63ffab6cc02f91aa545ab1
2023-07-17 14:53:37 +02:00
Guillaume DeMengin b8fa41f85f Use multiprocess to avoid pickle errors in tox on macos
Closes-Bug: #1998146
Change-Id: Id3ccee0f2f6ffb86c67b222f4cb0a869ba8c6bda
2023-07-17 13:55:02 +02:00
Antoine Musso 628c3d00e9 CI: move out of OpenStack Zuul templates
Use the ubuntu-xenial nodeset for most jobs.

Change-Id: Id33dd0195ef2fe617230b732eb51f93b0f5bd53b
2023-07-17 13:40:12 +02:00
Guillaume DeMengin 70dc3e4f71 Fix CI tests
Adjust some of the dependencies.

multi_key_dict is not shipped by OpenStack Zuul templates
`build-openstack-docs-pti` or `openstack-cover-jobs` we thus need to
depend on `requirements.txt`.

setuptools v66.0.0 removed support for PEP 440 non-conforming versions.
It provides pkg_resources which we use in PluginVersion.

Tox `whitelist_externals` has been renamed `allowlist_externals`.

Signed-off-by: Antoine Musso <hashar@free.fr>
Change-Id: Ie791c2bb0e7b3784913f45768d2f3db4c66ccae5
2023-03-16 21:06:36 +01:00
Michael Still d1e4696495 Handle new master naming in Jenkins post v2.307.
Closes-Bug: #1943402
Change-Id: I6789f6af325f2c104adb91ac7159e3734f71029f
2021-12-28 17:28:15 +11:00
Jim Wisniewski dc2b9447de Use fullname in get_job_info_regex
Use full job name in `get_job_info_regex` instead of just the name, so
that matches will work in folders as well.

Closes-Bug: 1685575
Change-Id: I97ba8ca004387b376a511ba52fc9fdd2aeb98a63
2021-12-14 23:39:03 +00:00
JP Sullivan 570a143c74 Allow build number to be a string
When retreiving data from builds, the build number can have a string portion.
This is for matrix jobs that define a label to retrieve one sub-build of the
matrix job.

The URL structure is:
https://<jenkins_server>/job/>job_name>/<number>/label=<configuration>/

Allowing a string for build number allows for it to be specifed as, e.g.:
1/label=amd64

And whilst being somewhat a workaround, works without introducing complexity
and modifying function calls for extra parameters.

Change-Id: Ic409df6e20e85d6a417c6490472b3729f1f20cd2
2020-11-23 10:40:27 +00:00
Marcin Cieślak 34254af2b0 Switch links for contributors to opendev.org or launchpad
Also change the mailing list address

Change-Id: I264010f2125831b1699b9d343a4de118bb7db972
Closes-Bug: #1872942
2020-08-01 09:27:53 +02:00
JP Sullivan 4aab17d404 Add retrieval of stages and artifacts
Enable calls to retreive artifacts from Jenkins and also to pull
the stages data from the wfapi endpoint.

Change-Id: I59eb403d54416ed45a918d98fc2f43c3c02441d0
2020-04-23 16:15:38 +01:00
Kazuhiro Suzuki 36f0b89766 Blacklist stestr 3.0.0 and drop pypy
stestr 3.0.0 does not support python 2.7 but has been released without
the proper metadata to reflect that. As a result, there is a python2 wheel
stestr-3.0.0-py2-none-any.whl which get picked up.

Blacklist stestr 3.0.0 to fix '--list': no such option error

Drop pypy testing since pypy jobs are always failling.

Signed-off-by: Antoine Musso <hashar@free.fr>
Signed-off-by: Andreas Jaeger <aj@suse.com>
Change-Id: Ia2f7c814f21c78f29ec9024997469625f92bc401
2020-04-17 14:46:18 +02:00
Zuul 9e66e45f0a Merge "Include placeholder tasks in get_running_builds" 2020-03-04 02:58:33 +00:00
Pascal Hofmann 19e7f7395a Include placeholder tasks in get_running_builds
Pipeline jobs in in Jenkins 2.x appear as placeholder tasks for their
entire lifetime when queried via the API. The fix for #1659787
introduced completly ignoring placeholder tasks. Thus pipeline jobs are
never included in the list returned by get_running_builds.

This commit will change the behaviour of get_running_builds as follows:
  - Placeholder tasks will be included: So running pipeline jobs
    will be included.
  - Builds which do not have a build number yet will be ignored:
    This prevents the exception described in #1659787.

Change-Id: I30351ec78d6186b0674e3c08be00076b0ce2333e
Closes-Bug: #1750372
Related-Bug: #1659787
2019-12-25 08:43:46 +01:00
Jeff Schroeder 9bf7f81509
Fix reconfig_credential() to send the xml data
Previously, reconfig_credential() passed empty `data` with
`Content-Length: 0` to the credentials configuration rather
than the credentials data.

This patch fixes the issue by passing the config_xml data to
the configuration API to properly update the credential.

Change-Id: Idef50f5a31d55991698b6217f55f15a9308b8526
2019-12-16 09:32:50 -05:00
Zuul 36c99d3436 Merge "new method: create_folder (with tests)" 2019-12-16 14:08:18 +00:00
Marcos Diez d6d510b59d new method: create_folder (with tests)
Change-Id: Ib21398c98d853aed4f4eea50270164e501fd18ce
2019-12-15 23:57:11 -03:00
Marcos Diez f222797332 new method: check_jenkinsfile_syntax (with tests)
Change-Id: I77a04c95ee3e4d9184bb418853ae414957bf0280
2019-12-15 23:41:38 -03:00
Zuul 306a40b3b4 Merge "upsert_job" 2019-12-09 15:07:01 +00:00
Andreas Jaeger 1749d4d2f5 Update docs building job
Replace the readthedocs template that warns about a broken setup
with a template that just builds the documents
(build-openstack-docs-pti) so that we can remove the obsolete template.

If the repo wants to use publish later to readthedocs, the template
can be changed to docs-on-readthedocs as explained in
http://lists.openstack.org/pipermail/openstack-dev/2018-August/132836.html

Change-Id: I343d16e6ec8180f4fd9ac058eaab06378ccee6bc
2019-09-29 18:05:55 +02:00
Marcos Diez 722a303f9a upsert_job
Change-Id: I1f389baf1c530b6e04860569deb5aca51bf781c2
2019-09-17 10:12:27 -03:00
Zuul 35f660a8b9 Merge "When updating jobs the response body may be empty" 2019-07-23 15:12:05 +00:00
Zuul ac7fc35b1b Merge "Make get_job_info fetch_all_builds work with jobs in folders" 2019-05-23 14:11:46 +00:00
K Jonathan Harker 0ab91c7a7c Remove pin on mock module
This was pinned for python26, which we no longer support.

Change-Id: I7dfd92c011b223d171ffd4be9c3f8c59fe87c6cf
2019-05-23 11:38:13 +00:00
Andreas Jaeger 748aa2068b Update jobs
The repo uses docs-on-read-the-docs, remove extra
build-openstack-sphinx gate job.

Without this change, two docs jobs would be building in gate, tox-docs
and build-sphinx. One is enough.

Also, use templates instead of individual jobs.

Import other templates from project-config, use the failing docs
template since readthedocs is not setup yet.

Remove publish-to-pypi, this should stay in project-config.

Fix sphinx requirements for python 3.

Fix decoding in failing test.

Change-Id: Ic4f715b45c1284ea49339e96c2aa87b2e81fcbea
2019-05-21 21:35:07 +02:00
Frank Lichtenheld 190fbbb5ad Make get_job_info fetch_all_builds work with jobs in folders
Make sure to use fullName from the API results to correctly
compute the URL for the additional API request.

Change-Id: I7ca1f2e15a6c40883ba376b182c2c991ca76e8b2
Closes-Bug:#1828051
2019-05-07 17:23:14 +02:00
OpenDev Sysadmins a5615d04f8 OpenDev Migration Patch
This commit was bulk generated and pushed by the OpenDev sysadmins
as a part of the Git hosting and code review systems migration
detailed in these mailing list posts:

http://lists.openstack.org/pipermail/openstack-discuss/2019-March/003603.html
http://lists.openstack.org/pipermail/openstack-discuss/2019-April/004920.html

Attempts have been made to correct repository namespaces and
hostnames based on simple pattern matching, but it's possible some
were updated incorrectly or missed entirely. Please reach out to us
via the contact information listed at https://opendev.org/ with any
questions you may have.
2019-04-19 19:49:46 +00:00
Jan Zerebecki a2c6f6a8ff
When updating jobs the response body may be empty
Other specific requests may need a body. Thus remove the general check
for an empty body and add a more specific one where needed.

I noticed this because when updating a Jenkins job with Jenkins Job
Builder I got an EmptyResponseException even though updating worked
correctly.

Change-Id: Ie144e6fb0b922a681e6c65ffbe5120da72a495f0
2019-01-07 21:52:19 +01:00
Zuul 5c287258eb Merge "add python 3.6 unit test job" 2018-12-27 11:31:41 +00:00
qingszhao 4a7c4ff539 Add Python 3.6 classifier to setup.cfg
Change-Id: Idca52cc5f2038db9a528bc5297b65e60a170ccb0
2018-11-29 09:40:08 +00:00
Vieri 9f77e68ef6 add python 3.6 unit test job
This is a mechanically generated patch to add a unit test job running
under Python 3.6 as part of the python3-first goal.

See the python3-first goal document for details:
https://governance.openstack.org/tc/goals/stein/python3-first.html

Change-Id: I80117242630a1aa6df39b33b0ab66616ab8923a9
Story: #2002586
2018-11-28 07:04:07 +00:00
Zuul 7166f872f5 Merge "Merge jobs_in_folder_named_job into jobs_in_folder" 2018-10-26 19:52:28 +00:00
huang.zhiping 81dd80922c Update min tox version to 2.0
The commands used by constraints need at least tox 2.0.  Update to
reflect reality, which should help with local running of constraints
targets.

Change-Id: I8146e56453c518f8d8ae822157c1e4931708959a
2018-10-21 02:20:04 +00:00
Zuul 5d1bb50bc3 Merge "Request multiple folder levels at once in get_all_jobs" 2018-10-19 15:36:37 +00:00
Zuul 2aef1bb5fb Merge "Make jjb-tox-cross-jenkins-job-builder voting" 2018-10-19 14:52:02 +00:00
Tomas Janousek c02b0b61c5 Merge jobs_in_folder_named_job into jobs_in_folder
Now that jobs_in_folder isn't reused in all other get_(all_)jobs tests
there's no more any reason to keep jobs_in_folder_named_job a separate
test.

Change-Id: Ic51a4b2cac3105cf9406d2a7864943a7df1248be
2018-10-17 18:06:56 +02:00
Tomas Janousek b5a8b7035e Request multiple folder levels at once in get_all_jobs
On our Jenkins instance with almost a hundred folders, JJB update
stalls for quite a while because it calls get_all_jobs. When invoked
locally at the Jenkins master, it's a matter of seconds, on a fast
broadband link and VPN, it's 2 minutes, and on a train it's easily 10
minutes.

But there's trick!

    curl \
        --show-error --silent --fail \
        --user : --negotiate \
        --get \
        --data-urlencode \
            tree=jobs\[url\,name\,jobs\[url\,name\,jobs\[url\,name\,\
            jobs\[url\,name\,jobs\[url\,name\,jobs\[url\,name\,\
            jobs\[url\,name\,jobs\[url\,name\,jobs\[url\,name\,\
            jobs\[url\,name\,jobs\]\]\]\]\]\]\]\]\]\]
        https://jenkins.example.com/api/json

This returns almost instantly.

And it gets better: if we fail to correctly guess the nesting level
necessary, Jenkins returns

    …, "jobs": [{}, {}, …], …

so we can easily detect that we need to recurse deeper.

Change-Id: I7268259149e4bc8939c512a112c7e6ec1908224f
2018-10-17 18:06:56 +02:00
Tomas Janousek 05986a64d7 Replace build_jobs_list_responses with actual Jenkins responses
This abstraction did more harm than good -- pretended to create correct
JSON responses from a simpler structure, but created responses that were
very far from what Jenkins would return:

* "url" fields didn't contain folders, but nobody noticed as these
  weren't used anyway

* "jobs" fields contained the string "null" (not JSON null, an actual
  JSON string!), whereas real Jenkins returns a list of almost empty
  objects (just a "class" field, if Jenkins is new enough, otherwise
  nothing)

* "color" field is absent from folders

The usage of deepcopy, insert and append totally obstructed the real
contents of those responses from most readers. Let's just be a bit
verbose here, please.

Change-Id: Ida2cfa3662e491e4178228096dc622cdd859202f
2018-10-17 18:06:56 +02:00
Tomas Janousek 49d6c92d0c Clean up job/folder path handling
Avoid repeatedly serializing and splitting the root path component of
jobs being added to the list to be processed and returned.

Attempting to split a string path using 'job' introduces a bug if a job
ever happens to also use the name 'job' as part of its name. This could
be fixed by using root.split('/job/') but it still seems hackish.

Maintain the root path to the folder in the hierarchy as a list of path
components, add to it when descending and store the result of joining
it with '/job/' as a separate variable to avoid needing to re-parse.

Change-Id: I074ad74ad935c50716141a79822ca84999734c3f
2018-10-17 18:06:56 +02:00
Tomas Janousek b1564e94b5 Test requested URLs in test_getall
This would've caught that the info parameter is ignored in get_info and
I'm going to refactor/improve get_all_jobs so I need stricter tests
anyway.

Also, this makes test_unsafe_chars useful. Before it was a totally
meaningless test that didn't test anything at all. :-(

(Actually the get_info problem was caught by this test, but I'm
committing the fix first to not break git bisect.)

Change-Id: Ifd06bbbd9969a2739322e36ae83f521490a6eaa0
2018-10-17 18:06:56 +02:00
Sorin Sbarnea 8cdf785514 Make jjb-tox-cross-jenkins-job-builder voting
Avoid accidents where python-jenkins change may break jjb. Job
run succesfully for months.

Change-Id: Icd0d49ab2876af16fbc45afe2e554744f42bc649
2018-10-05 18:35:04 +01:00
Zuul afa1e05e74 Merge "Check for 'Location' header in the response" 2018-09-21 14:11:48 +00:00
Zuul ede93173e3 Merge "Add folder credential support" 2018-09-21 13:46:39 +00:00
Aigars Mahinovs 811a6cffc8 Allow adding extra HTTP headers to Jenkins requests
In some network setups Jenkins may be hidden behind complex reverse
proxy setups that require additional custom headers to be set on
each request in order to pass them trough

Allow providing such headers using JENKINS_API_EXTRA_HEADERS environment
variable

Change-Id: If071c5c707f916ba5f4f2c371ec600b7476bf723
2018-09-12 13:42:23 +02:00
Thanh Ha 93515ae07d
Revert "detect and respect http redirects"
This reverts commit 4150a83d45.

Change-Id: I972404ff936cbd3c0fe164dcbaa186d5e530736c
2018-08-24 13:12:38 -04:00