Switch create node to pass form data via request body, removing the
need for special handling in the _build_url method. Consequently remove
the string placeholder in the endpoint format string.
Remove unnecessary parameters of name and type from inclusion in the
json form data item, confirming they are ignored and required to be set
in the main form data.
Tested against jenkins 2.19.4.
Change-Id: I5f8f870a2ee3539505e984abccb0c87c632c1b9a
Prior to this change, create_node() would double-encode certain url
params: once when quote()'ing in _get_encoded_params(), and again in
urlencode().
This would cause HTTP 400 errors when creating a node with a name that
contains a url-encodable character, like "my+test+node".
Reviewed-by: Alfredo Deza <adeza@redhat.com>
Change-Id: I237e2988e168af81e623d3f065753f2e9b617696
When there are placeholder tasks in an executor for a node then there is no
build number yet assigned and attempting to access that key in the dictionary
will fail.
This fix filters out any tasks which are instances of that class before
proceeding.
Change-Id: Ie5b237c3e6023c1822f91e5982ec84f1a363130c
Closes-Bug: #1659787
During Jenkins deployment via e.g. puppet jenkins might be started but
not yet serving requests. Allow to wait for jenkins to enter normal
operation mode and fail if it doesn't show up after N seconds.
Allow for 0 seconds to just test and return success or failure without
any waiting.
This will allow us to avoid open coding "is jenkins ready?" for
different provisioners like puppet, chef, salt, ansible, ... when this
gets jused by jjb.
Change-Id: I7fd8aed43f571528f27dac681cc1e1f77a0e0ad7
Co-Authored-By: Darragh Bailey <dbailey@hp.com>
Groovy scripts may contain characters that need to be escaped prior
to being passed to Jenkins' REST API; for example "&&" in condition
testing. Not doing so will result in a script execution failure on
the server.
Change-Id: Ied6c2a48392cadbadb84865dad47ceed99e694a1
When the server has an URL path such as http://example.org/ci/, the
get_running_builds() would fail to extract the job name from the
executor informations. It most probably fails when using CloudBees
folder as well.
Relax the regex used to detect the job name by changing match() with
search().
Update JenkinsListRunningBuildsTest so it craft the URLs based on the
test scenario (make_url) instead of hardcoding them. That would have
caught the bug. See 2aa1a5f1 which introduced the scenarios.
Signed-off-by: Antoine Musso <hashar@free.fr>
Change-Id: I1b69adf121ee74e3336ac9bd1d4d55797fb72de5
python-jenkins fails to build without the kerberose packages and those
packages are not included in our xenial images. Use bindep to
configure the required minimum set of required packages.
build error:
building 'kerberos' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes
-fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong
-Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/base64.c
-o build/temp.linux-x86_64-2.7/src/base64.o sh: 1: krb5-config: not found
x86_64-linux-gnu-gcc: error: sh:: No such file or directory
x86_64-linux-gnu-gcc: error: 1:: No such file or directory
x86_64-linux-gnu-gcc: error: krb5-config:: No such file or directory
x86_64-linux-gnu-gcc: error: not: No such file or directory
x86_64-linux-gnu-gcc: error: found: No such file or directory
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for kerberos
Change-Id: Iad6e10ef6ef05e0b5c6db08dbb97b2c3a3e42a30
This change removes a `warnings.simplefilter` call that forced
`DeprecationWarning` occurrences (whether they are generated by this
library or any other code) to be displayed to the user. This call caused
Jenkins Job Builder, for example, to display several developer-targeted
warnings that are not helpful to the final user.
According to the Python documentation:
> Warnings that are only of interest to the developer are ignored by
> default. […] Having certain warnings ignored by default is done to
> prevent a user from seeing warnings that are only of interest to the
> developer. […] While you as a developer want to be notified that your
> code is using a deprecated module, to a user this information is
> essentially noise and provides no benefit to them.
(https://docs.python.org/2/library/warnings.html#updating-code-for-new-versions-of-python)
Change-Id: I31d4c6bd494361aa153fd59e2ceb6bedccd280bc
urllib.request.Request.get_host() is removed in python >=3.4 in favor of
urllib.request.Request.host. It works in python 2.7 too.
Update the test to use Mock with spec where applicable, to ensure that
only available attributes are accessed.
Change-Id: I0e6a4e1539f9db329b6f113207d52f171cc600a7
Jenkins only provides 100 builds of a job with the job info. This
makes python-jenkins fetch all builds when there are more than 100.
Change-Id: I326efa11c975e036b65a159414062966239c9749
This patch adds the new `view_name` argument
to the `get_jobs` method that limits the list of jobs
returned to only those configured in the view specified.
Change-Id: I78266ed13cd6c183a2f4858458817455b79d9a23
Check if "kerberos" package can be imported at runtime
(in __init__.py). If not, everything works as before.
If "kerberos" package can be imported register a new
urllib handler (defined in urllib_kerb.py) which adds
support for kerberos auth.
This urllib handler (urllib_kerb.py) is only triggered
on 401 (Unauthorized) response, and we try to auth
with kerberos. If unsuccessful, next 401 handler (if any)
is triggered.
Change-Id: I1a47e455aa14535a124df950994718a11d7e4f57
Promotions can be attached to jobs via the REST API described at:
https://issues.jenkins-ci.org/browse/JENKINS-8963
Co-Authored-By: Guido Günther <agx@sigxcpu.org>
Co-Authored-By: Joao Vale <jpvale@gmail.com>
Change-Id: I756a35f53f96ba6e46e71f36ea99f62d32b604d2
"Python 3.3 support is being dropped since OpenStack Liberty."
written in following URL.
https://wiki.openstack.org/wiki/Python3
And already the infra team and the oslo team are dropping py33
support from their projects.
Since we rely on oslo for a lot of our work, and depend on infra
for our CI, we should drop py33 support too.
Change-Id: Id129b5c418ad49ea805888309d031ff8a9960be9
Closes-Bug: #1526170
Fixed create_node() raises HTTP Error 400 Bad Request
This issue caused by:
self.jenkins_open(Request(
self._build_url(CREATE_NODE, params), b''))
The "params" dictionary of options isn't parsed correctly
during _build_url funciton that Jenkins is expecting
Fixed it use urlencode to parse the params and construct
the URL
Change-Id: I85fa43bc0b4ff1530133b862734e94aede9b44a5
Closes-Bug: #1500898
It's important to check that we correctly handle the server url for all
API calls, so ensure that the test code uses test scenarios to cover.
Fix get_info() api call creation of url.
Change-Id: Idb0becc4c0c56df81bc5545919e530b7a77dadc9
There are cases where asking for depth>0 node_info will 500. This breaks
listing jobs because we raise and stop looking for running jobs. Handle
this by checking if it is a 500 error at depth=2 and if so check
depth=0. If that returns successfully treat it as a broken slave that
isn't running any jobs.
If depth=0 returns an error things are probably much more broken and
should be looked into.
Change-Id: Ieac15a0fe2a47ec3dae51db96ad2fe40992c353a
To allow PluginVersion class to be passed to builtin functions expecting
a string type, need to use 'str' as the base class. This ensures
the change to support version comparison is completely transparent to
the calling code, but permits changes to benefit from the new behaviour
without breaking existing usage.
Change-Id: I7d434294fa45171e47ea4876d01398cb75f5d962
Add the ability to install the latest version of a Jenkins plugin.
Thanks to Fatih Degirmenci for providing the groovy script[1]
[1] http://pastebin.com/9qWeVYSP
Change-Id: I67a0b02710a9f5007a6529d87222e5777e744337
Add some common management and version comparison capabilities via
dedicated classes to simplify how calling libraries can perform version
checks on the installed plugins.
Update the comments on the existing methods to note that they return the
raw plugin data in JSON format instead of the parsed local objects.
Change-Id: If43bb945f55c6fb9f8a6595091eace12e4630ffa
We can discover the next build number Jenkins will use for a particular
job using get_job_info(), but there's currently no way through
python-jenkins to set the next build number. This change introduces
the set_next_build_number() method which, given a job name and a
desired number, sets the next build number of the named job to the
given number.
Limitations: Jenkins enforces that build numbers must be monotonically
increasing, but gives no indication of an error; it simply ignores the
offending value.
Change-Id: I23b5a84b7ea37d66bf778a89343e3c81ffa9ceb6
This patch adds cloudbees folder plugin support. Folder should be
specified in job name : <folder>/<job>
This update also extend job_builder
(http://ci.openstack.org/jenkins-job-builder/) tool without any
modification.
Change-Id: I6d3957c217e1253e53152d90d5fcce5e69c77674
Co-Authored-By: Darragh Bailey <daragh.bailey@gmail.com>
It can be useful to get a list of running builds from jenkins. This is
particularly useful when you need to take an action on a specific built
or if you need to know when the jenkins master has finished running all
builds (say after quieting down). Add a function to return this list.
Change-Id: I5c7dac8076250f94cd2b358c5b153d9410f53aee
If we run python3 tests before python2 tests the testrepository DB works
fine. If we run python2 first the python3 tests cannot read the
testrepository DB. The simple fix here is to change the order of the tox
env list so that python3 always runs first.
Change-Id: I5118c65f07c0f761e211cd2f186ab11d2f8a3393