Commit Graph

249 Commits (20fd8c40cf04b74db1bb5941deb729fe7b5f6375)

Author SHA1 Message Date
Sorin Sbarnea 20fd8c40cf
Added pypy-dev to bindep.txt
Fixes failure to install some packages on pypy
due to missing python headers.

Change-Id: I4d693e3119bfcf5db4999b640c030f9389e53d27
2018-06-16 21:17:34 +01:00
Zuul 3d59064908 Merge "Selectively mock requests_kerberos import" 2018-06-12 18:06:01 +00:00
Darragh Bailey f56e719ec9 Selectively mock requests_kerberos import
To ensure consistent test behaviour need to mock the import of
requests_kerberos to be None only for the test classes based
off of the default JenkinsTestBase

Change-Id: I79903a6b3e4a1677fa1a1980af9f73c84b385828
Depends-On: I56c9580be9a90f5cda7349a148d467e6ff4e9270
2018-06-01 15:07:12 +01:00
Darragh Bailey 45529fba54 Ensure timeout exceptions are re-raised during auth attempts
Timeouts are different to auth failures, make sure to re-raise them
while attempting multiple authentications.

Change-Id: I56c9580be9a90f5cda7349a148d467e6ff4e9270
2018-06-01 10:48:54 +01:00
Zuul a3c3672a6f Merge "Fix: send proxy as empty dict" 2018-05-31 18:50:49 +00:00
Sorin Sbarnea e391e92bad Revert "Do not require requests-kerberos for tests"
This reverts commit 1946ed303b.

Change-Id: If4b1db131af467eb9a0910584c0fdc08dcee10c6
2018-05-30 16:51:44 +00:00
Sorin Sbarnea ce56780909
Freeze cmd2 library on python2
The cmd2-0.9.0 is python3-only. Let's freeze the cmd2<0.9.0 as
recommended in https://pypi.org/project/cmd2/ while allowing any newer version on python 3+.

Change-Id: I5e631603e162da1d93347f954c9bc1af3f69597c
2018-05-30 17:03:24 +01:00
Zuul cd440ab4ac Merge "Do not require requests-kerberos for tests" 2018-05-23 10:02:36 +00:00
Ken Dreyer e4ad9dc086 README: mention #openstack-jjb channel
We use this channel to discuss both python-jenkins and
jenkins-job-builder.

Point python-jenkins users at this channel.

Change-Id: If6f1a62a820557275fac467330e7c5b84990408d
2018-05-21 09:57:07 -06:00
Zuul 892cd41f94 Merge "Update to _response_handler" 2018-05-19 21:42:19 +00:00
Jan Hruban 1946ed303b Do not require requests-kerberos for tests
The test for kerberos was dropped in
34cca0c4d9, as it was not needed for the
simpler implementation with requests. Let's drop the requests-kerberos
from test dependencies as well, as it has only caused troubles in other
tests - at least for me.

One had to set jenkins.requests_kerberos to None, as was done in the
tests.base.JenkinsTestBase. In places where it was not set to None, the
jenkins.Jenkins.jenkins_open tried the kerberos authentication in
addition to anonymous authentication on the /api/json endpoint.

This was the case for
  tests.test_jenkins_sockets.JenkinsRequestTimeoutTests.test_jenkins_open_timeout
where it has resulted in a different exception than was expected:

  Traceback (most recent call last):
    File "tests/test_jenkins_sockets.py", line 31, in test_jenkins_open_timeout
      j.jenkins_open(request, add_crumb=False)
    File "jenkins/__init__.py", line 533, in jenkins_open
      return self.jenkins_request(req, add_crumb, resolve_auth).text
    File "jenkins/__init__.py", line 547, in jenkins_request
      self._maybe_add_auth()
    File "jenkins/__init__.py", line 384, in _maybe_add_auth
      % '\n'.join(failures))
  jenkins.JenkinsException: Unable to authenticate with any scheme:
  auth(kerberos) Error in request: HTTPConnectionPool(host='127.0.0.1', port=33921): Read timed out. (read timeout=0.1)
  auth(anonymous) Error in request: HTTPConnectionPool(host='127.0.0.1', port=33921): Read timed out. (read timeout=0.1)

Change-Id: I45cbb3a666ee6a9ecbe628ca8b7f0b07dcfcb0eb
2018-05-11 22:24:36 +02:00
Brad Brown a11edaca52 Fix: send proxy as empty dict
Change-Id: Ie713479ef5a468a22bc71f220166b438a91d5877
2018-05-01 06:46:18 -05:00
JP Sullivan 827f28a223 Add functions to retrieve more data from Jenkins
If tests results are added to builds, or environment variables are injected
into a job, there are separate API calls to retrieve that data.  Add functions
to do so.

Change-Id: Ie0a51839d527db6d440719eeb44cd1cc89644d06
2018-04-25 13:30:29 +01:00
JP Sullivan 5033405db7 Update to _response_handler
Account for situations where no Content-Length or Transfer-Encoding
headers are present in a response.

The length of the response.content could still indicate a response was
given.  The earlier raise_for_status() should catch bad HTTP responses
that return content.

Closes-bug: #1766660
Change-Id: I6739e26a039a898982f5cdc96d19d6992ed37737
2018-04-25 12:36:20 +01:00
melissaml 5f5d54b897 Trivial: Update pypi url to new url
Pypi url changed from [1] to [2]

[1] https://pypi.python.org/pypi/<package>
[2] https://pypi.org/project/<package>

Change-Id: I65b8ae7c71601542bf17230d380e518a23034f23
2018-04-21 08:40:51 +08:00
Zuul 5c913ca185 Merge "add get_queue_item() method" 2018-04-17 19:27:23 +00:00
Zuul 27201edd51 Merge "build_job: return queue item identifier" 2018-04-17 19:08:58 +00:00
Zuul ca86352248 Merge "add jenkins_request() method" 2018-04-17 18:45:22 +00:00
Ken Dreyer 284c3d37b7 add get_queue_item() method
Pass in a queue ID number to discover a job's status, and possibly a job
URL.

Change-Id: I20541ec49cc30e5c74a6c596e02b3f42b2567fa5
Closes-Bug: #1724932
2018-04-17 12:27:32 -06:00
Ken Dreyer 91ab3d9057 build_job: return queue item identifier
Since Jenkins version 1.519 (released 2013/06/17), build_job() would
always return an empty string (the empty HTTP body from the POST
request).

Read the HTTP response's Location header and return the queue ID number.

Clients can use this number to query server for the the upcoming job's
status.

Change-Id: I2a1ef3abb7e675e0ad37dd8eb4a377af22f27a03
Closes-Bug: #1724932
2018-04-17 12:27:32 -06:00
Ken Dreyer f3ba366a69 add jenkins_request() method
Move the main pieces of the jenkins_open() method out into a new
jenkins_request() method.

This makes the raw requests.Response object available to other callers,
so they can access things that were not in the response's body string,
such as the response headers.

Change-Id: I1f4049899cf3fa25e6159c416a325419b91e322e
Closes-Bug: #1724932
2018-04-17 12:27:31 -06:00
Zuul dc6e7cc1e8 Merge "Fix docstrings params" 2018-04-17 09:35:22 +00:00
Eduardo Gonzalez 17b8942733 Use proper code highlight in docs
Specify if is python, xml or bash the code blocks
in examples.
Fixes a couple doc build warnings

Change-Id: I3ea9f3aabe23656752c23c843c297f3872454a17
2018-04-17 10:27:59 +02:00
Eduardo Gonzalez e4f34ee815 Fix docstrings params
Some docstring params doens't match with the param expected
from the function.
Also fixes some param ordering to match the order the function
expects them.

Change-Id: Ia2b4d71ab46cc326f0a1bcbd83d2bf58937bfed4
2018-04-17 08:18:19 +00:00
Teemu Patja 08f76f724d Adds support for wiping out a job's workspace
Support for wiping out a Jenkins job's workspace.

Change-Id: I8daa4a6fe7976c90ca59c89bda775d83aff7b622
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2018-04-15 16:23:04 +01:00
Zuul abe6df6d1d Merge "Adds support for multi-select build parameters" 2018-04-15 09:44:55 +00:00
Akshat Tandon 96f0a7fa5f Adds support for multi-select build parameters
This feature will allow build_job to accept build parameters as a list
of two membered tuples - [('parameter key', 'parameter value', ), ...].
Currently, build_job expects to receive a dictionary of parameters but
this limits the build_job_url function (which is called from
build_job()) to build jenkins url for jobs with multi-select
parameter(s) because dictionaries cannot have duplicate keys (in case,
when there are several values to one parameter key). urlencode is
capable of converting lists with two membered tuples to url as well.

Change-Id: I134a5f8b69ba91acd89afa791cb1cf0b5e63f5f5
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2018-04-14 07:34:21 +01:00
Teemu Patja 03ed39ba01 Adds support for deleting builds
Support for deleting individual builds for a Jenkins job.

Change-Id: I35c98855b0883986a85cbe7212ec52e6f67e5638
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2018-04-13 18:23:47 +01:00
Sorin Sbarnea e15a54bdc3 enable cross testing with jenkins-job-builder
Adds a new job that tests if change affects jenkins-job-builder
master branch in order to avoid introducing breaking changes
in the most important consumer of the this library.

Also adds an optional tox target named tips which can be used
by developers to perform the same kind of testing. This
mimics the same kind of testing that was already implemented
inside jenkins-job-builder.

Change-Id: I594347c431a881227c5090b41b4ba4ef50e3133f
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2018-04-13 16:49:18 +01:00
Sorin Sbarnea fada8b14b1 Improve SSL support with requests lib
* Avoids multiple warnings when PYTHONHTTPSVERIFY=0

* Uses certs from REQUESTS_CA_BUNDLE or CURL_CA_BUNDLE when defined
just like default requests default behaviour. Previous code was
failing to use them due to wrong value being used for verify param.

* Uses workaround for requests bug that ignores verify=False when
bundle environment variables are present.

Change-Id: I329fb08547392bd305066f5a65e7d9db57da3880
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2018-04-13 12:50:53 +01:00
Zuul 1ef634f18f Merge "Adding pypy to bindep test profile" 2018-04-12 00:57:08 +00:00
Sorin Sbarnea 5d9d6dd4a0 Enables use of PYTHONHTTPSVERIFY override
Since we switched to requests library, SSL verification
changed. In order to avoid breaking users that were
using non globally recognized certificates we
detect if PYTHONHTTPSVERIFY=0 is defined and disable
requests SSL verfication.

This has no effect if this variable is not defined as
we do not want to have any insecure defaults.

Change-Id: I2ea7ebb97f806e915b5b96a3f9ec47d48b039ad2
2018-04-11 18:09:58 +00:00
Sorin Sbarnea 569878373c Adding pypy to bindep test profile
Avoid zuul failure to find pypy interpreter on gate.

Change-Id: Ied12cc7a110c87f0e295ad645a9208db9f8f5a89
2018-04-11 16:56:05 +01:00
Amadeusz Kryze e539017eef Added folder support in views keeping backward compatibility and added tests for it.
Change-Id: I48c231cd1b9a038ede526e7e7a50e65af8aaf13b
2018-04-05 22:57:34 +02:00
Zuul 0d0c12bc80 Merge "Add EMPTY_FOLDER_XML str to match docs" 2018-04-05 12:31:47 +00:00
Andrew Mellen a2cfa306c2 Add EMPTY_FOLDER_XML str to match docs
Change-Id: Ic36ccaa897b8334877b7706e30276103381f9380
Closes-Bug: #1605491
2018-04-05 12:15:08 +00:00
Ken Dreyer b5937bfd3e build_job: fix grammar in comment
Drop the "s" from the infinitive "to extend".

Change-Id: Iaf8449e61c8af9eef3eb90ec0ed3572e51f77a2d
2018-04-05 12:14:38 +00:00
Zuul 87283efaf0 Merge "get_job_name: fix grammar in comment" 2018-04-05 12:13:42 +00:00
Sorin Sbarnea 9f143f1241 Replace testr with stestr
Switch to use stestr which is maintained as opposed
to testrepository (testr) which became a defunct project.

Change-Id: If53c985b6cf3b4122596f09ec4d0ec4a186688b8
2018-04-04 23:25:21 +01:00
Zuul c902397b29 Merge "get_build_console_output: fix docs for "number" parameter" 2018-04-04 22:10:22 +00:00
Zuul 58f51411e1 Merge "repair .gitgnore" 2018-04-04 22:03:07 +00:00
Zuul 7166e97eb2 Merge "Migration to using requests" 2018-04-04 20:40:17 +00:00
Zuul b8d2f6d444 Merge "Pass form data as body instead of in the url" 2018-04-04 20:37:21 +00:00
Zuul 4a660eefe1 Merge "modify version spelling errors" 2018-04-02 16:47:37 +00:00
Zuul eb8658508e Merge "trivial: modify spelling error of version" 2018-03-03 16:45:22 +00:00
Ayoub Elhamdani b7f0f717fc This Allow to include folders in jobs list when calling get_all_jobs()
method.
Closes-Bug: #1731903

Change-Id: Ib55d58c96f2bc4543db1b85336c04e4c6cd81021
2018-02-28 10:21:22 +00:00
Sorin Sbarnea 2d8a213729 repair .gitgnore
- remove duplicate /MANIFEST entry
- sorted list to avoid future confusions
- added generated AUTHORS and ChangeLog

Change-Id: I64cce1ac001e62aed5704a746a9fa76f314ba565
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2018-02-28 10:20:01 +00:00
Darragh Bailey 34cca0c4d9 Migration to using requests
Convert to the requests library to allow for more sophisticated response
handling to be added.

Want to allow for applications to override the response handling in
certain cases where the default is incorrect. Handling of urlopen
responses results in version specific handling to ensure correct
behaviour across multiple versions of python.

Changing to use the requests package, provides a higher level interface
and removes some of the version specific handling for exceptions.

Change-Id: I5369a0d35be4bf8b3b197a51e60aba21b5742cc7
Depends-On: Iabd70aa457ceb4dbc147d7cbaeec913148cb3b56
2018-02-12 11:16:54 +00:00
lvxianguo 151598d20a trivial: modify spelling error of version
Change-Id: Ibdbdc5437b2042bd6ec76ec789f66bd593a52d40
2018-01-18 10:25:52 +08:00
sunyandi d8c8715f03 modify version spelling errors
Change-Id: Idcef77d03863a6793dc00100027037df8756a087
2018-01-17 11:12:44 +08:00