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
Timeouts are different to auth failures, make sure to re-raise them
while attempting multiple authentications.
Change-Id: I56c9580be9a90f5cda7349a148d467e6ff4e9270
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
We use this channel to discuss both python-jenkins and
jenkins-job-builder.
Point python-jenkins users at this channel.
Change-Id: If6f1a62a820557275fac467330e7c5b84990408d
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
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
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
Pass in a queue ID number to discover a job's status, and possibly a job
URL.
Change-Id: I20541ec49cc30e5c74a6c596e02b3f42b2567fa5
Closes-Bug: #1724932
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
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
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
Support for wiping out a Jenkins job's workspace.
Change-Id: I8daa4a6fe7976c90ca59c89bda775d83aff7b622
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
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>
Support for deleting individual builds for a Jenkins job.
Change-Id: I35c98855b0883986a85cbe7212ec52e6f67e5638
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
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>
* 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>
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
Switch to use stestr which is maintained as opposed
to testrepository (testr) which became a defunct project.
Change-Id: If53c985b6cf3b4122596f09ec4d0ec4a186688b8
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