Commit Graph

179 Commits

Author SHA1 Message Date
Swapnil Kulkarni (coolsvap)
ac0ca9fbf4 Remove discover from test-requirements
It's only needed for python < 2.7 which is not supported

Change-Id: I8364eaa7b8b6189f8c0545d30697d40823e1b050
2016-07-22 04:02:12 +00:00
Jenkins
2e389ce44b Merge "Do not force DeprecationWarning to be displayed" 2016-07-14 17:19:07 +00:00
Jenkins
d149d0aed0 Merge "Fixed a minor typo in example of Python-jenkins" 2016-07-14 16:30:37 +00:00
Khai Do
5e99b853bc Setup required packages with bindep
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
2016-07-13 10:14:35 -07:00
Jonathan Perret
5cbdccfb81 Do not force DeprecationWarning to be displayed
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
2016-07-13 12:21:51 +02:00
Abhijeet Kasurde
fc0600c035 Fixed a minor typo in example of Python-jenkins
Change-Id: Id99b7bc1f68f98da23c7b62227cbf673915cd991
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2016-07-04 18:10:30 +05:30
Jenkins
4d495afe74 Merge "Fetch all builds from a job" 2016-05-19 05:26:40 +00:00
Jenkins
e39c4dcbd1 Merge "Make the kerberos support python3 ready" 2016-04-29 19:06:12 +00:00
Jan Hruban
d2cfca68d0 Make the kerberos support python3 ready
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
2016-04-29 19:30:24 +02:00
Chris St. Pierre
0881b20cbf Fetch all builds from a job
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
2016-04-29 16:22:34 +00:00
Ken Dreyer
fd8c8151b9 add get_whoami()
This function is useful for simply testing that a user's authentication
credentials are correct.

Change-Id: I07841eccd9cd2015ac432c9c22fb8e451a638c0c
2016-04-21 07:45:19 -06:00
Aliaksandr Buhayeu
f6f26ec481 Adds possibility to retrieve all jobs from the view specified
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
2016-02-22 18:03:48 +03:00
Jenkins
6728d36463 Merge "Add optional kerberos support" 2016-01-27 23:38:09 +00:00
Lukas Vacek
4152a0138b Add optional kerberos support
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
2016-01-27 23:08:04 +01:00
Guido Günther
0c503b724c Add support for handling promotions
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
2016-01-13 18:14:39 +01:00
shu-mutou
dccae5fd10 Drop py33 support
"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
2015-12-15 17:58:03 +09:00
Jenkins
4cace9dadf Merge "Deprecated tox -downloadcache option removed" 2015-12-14 19:59:09 +00:00
Dong Ma
302eb5dad6 Fixed create_node() Error
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
2015-12-12 18:35:03 +08:00
Ondřej Nový
83c53c4e71 Deprecated tox -downloadcache option removed
Caching is enabled by default from pip version 6.0

More info:
https://testrun.org/tox/latest/config.html#confval-downloadcache=path
https://pip.pypa.io/en/stable/reference/pip_install/#caching

Change-Id: Ib6b624be80e9e562d5204333b291a2b2ea3d8958
2015-12-11 21:25:03 +01:00
Jenkins
4c0536b428 Merge "Use TestWithScenarios to add additional url tests" 2015-12-02 19:50:08 +00:00
Darragh Bailey
2aa1a5f1b8 Use TestWithScenarios to add additional url tests
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
2015-12-02 11:35:59 -08:00
venkatamahesh
46a2f0a039 Change repositories from stackforge to openstack
Change-Id: I6ee5446f2e99da14edadf43491a970c7d91f788f
2015-11-03 06:39:27 +05:30
Jeremy Stanley
3b2dc286c9 Update .gitreview for new namespace
Change-Id: I55daf7c070f7a0a619e7a4376c6534cdf0cf483f
2015-10-17 22:37:18 +00:00
Clark Boylan
ce69828653 Handle depth errors in get_running_builds
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
2015-10-07 17:01:55 -07:00
Darragh Bailey
87a892a232 Use str as base class for PluginVersion
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
2015-09-29 18:08:21 +01:00
Jenkins
344b5f3ffa Merge "Provider helper classes for plugin data management" 2015-09-28 17:34:05 +00:00
Khai Do
0167b7f8f9 Support ability to install plugins
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
2015-09-28 10:21:21 -07:00
Darragh Bailey
8b3023dc18 Provider helper classes for plugin data management
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
2015-09-28 18:15:57 +01:00
Kevin L. Mitchell
244b4fed30 Allow setting the next build number
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
2015-09-24 10:06:05 -05:00
Jerome Hourquebie
7267eec454 Adds Cloudbees folder plugin support
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>
2015-09-21 18:25:35 +01:00
Clark Boylan
f80e54b4bc Add function to get running builds
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
2015-09-15 15:54:20 -07:00
Clark Boylan
f763f5c703 Change order of tox envs for testr
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
2015-09-15 10:24:36 -07:00
Jenkins
8923e660a9 Merge "Add support for quiet down" 2015-09-14 22:42:47 +00:00
Clark Boylan
338294b3f4 Add support for quiet down
This adds a Jenkins.quiet_down() method which can be used to quiet down
the server. Unit tests included.

Change-Id: I4e229aae6ad766bc6194a643fcd514e5538d6fa7
2015-09-14 13:10:54 -07:00
Khai Do
d1713ad228 fix get version example
Change-Id: I8fbcd518c078fbe15a99cc709072b86f93dad669
2015-09-10 12:08:43 -07:00
Jenkins
427753c3b1 Merge "Stop specifying requirements.txt in tox.ini" 2015-09-07 21:08:20 +00:00
Khai Do
5b39f6b309 remove support for python 2.6
We no longer support python 2.6 so removing it from tox.

Change-Id: I225c15a35e089556ab6115c96a7f7c5fff33ccab
2015-08-25 10:46:28 -07:00
Darragh Bailey
c58ae7e1af Separate tests in separate files and classes
Split existing tests into separate files and classes to make it easier
to select a subset to be executed when making modifications.

Add some simple consolidations of test data as example improvements that
can be extended by consolidating complete tests or sets of tests.

Change-Id: If2380e6f4e848ba68f05868e2ef4186d7912952b
2015-08-25 01:11:47 +01:00
Darragh Bailey
acd614fae7 Create module member index from autodoc
Change where noindex is used to allow indexing of all the jenkins object
methods. This allows for cross reference links to methods to be created
in the documentation and sphinx will automatically generate the
necessary links.

Change-Id: Ic9c28debca382a003ae9560f0bf7943c35ef187d
2015-08-25 00:49:06 +01:00
Darragh Bailey
a8655eaccc Fix timeout function and add capturing of messages on failure
Ensure process terminate is only called after checking whether the
process is still running so as not to accidentally set an exitcode.
Additionally include improved message exchange and capturing to allow
for easier debug should the expected exceptions not appear on socket
timeouts.

Change-Id: Ic51745ffa67570e9a3ca4574d2bfc54d0cd6724b
2015-08-17 18:09:19 +01:00
Jenkins
1647facd43 Merge "Wrap url building with helper method" 2015-08-14 20:31:05 +00:00
Khai Do
5d36768876 Stop specifying requirements.txt in tox.ini
As PBR already injects the contents of requirements.txt into
setup_requires, there is no need for tox to explicitly install them.
http://lists.openstack.org/pipermail/openstack-dev/2015-July/069663.html

Change-Id: Ice43f68c296178b1ad966d0ed5ed1add9bd13ce5
2015-08-10 13:53:31 -07:00
Jenkins
5b8fbd3640 Merge "Rework the examples" 2015-08-10 20:00:46 +00:00
Darragh Bailey
35a5938d0f Wrap url building with helper method
Move to using a helper method for constructing urls to ensure that call
interpolation is done using urlencoded values.

Change-Id: I318456a26a8651a8369e3a396b69354cb3793e43
2015-08-10 12:10:12 +01:00
Khai Do
f0989dd2ba Rework the examples
Create additional examples to help users get started.

Change-Id: I609dd06ee33033ae5efc18fa39ce920721998412
2015-08-06 06:27:26 -07:00
Darragh Bailey
0a1b414f3a Add socket timeout tests and helpers
Add tests that use a simple socket server instance that opens the port
and ignores all data in order to support testing when the socket timeout
is set and catching the exception triggered. Also test that when not set
that the request will continue to remain connected for a period of time
longer than the other test using a wrapper time limit process.

Includes some helper classes to black hole all requests by simply
listening using a socketserver but never accepting connections, and a
time limit function to allow wrapping actions with a time limit when
checking for blocking behaviour where the call should not return and
will need to be focibly terminated.

Change-Id: Idab98b0121adb26aed6320ddcf2afbdf2c4428e0
2015-07-24 18:32:40 +01:00
Jenkins
c83e9b1dc1 Merge "Fix tests on python 2.6 and mark as deprecated" 2015-07-13 22:10:46 +00:00
Jenkins
b5260c0d12 Merge "Support scriptText api to execute groovy scripts on the server" 2015-07-13 17:44:10 +00:00
Darragh Bailey
d47b37d07d Fix tests on python 2.6 and mark as deprecated
Pin mock to < 1.1 as newer versions no longer work on python 2.6.
Remove duplicate unittest2 for python 2.6 test env.
Adding warning to mark python 2.6 support as deprecated and intended to
be removed.

Testtools re-added the requirement for unittest2 so the separate
dependency for python 2.6 created a duplicate error that causes tox
to fail.

Change-Id: Ia79eeeb5d2432cf1025631a1722de5fb1babe2c9
2015-07-13 18:36:12 +01:00
Darragh Bailey
edf33b3139 Remove unneeded wrapping of imports
Remove the path injection being added by the helper module which was a
carry over from when the tests where executed directly via Makefile.

Change-Id: I435f039d75fdf55b295060656d071b011190973d
2015-07-08 11:19:18 +01:00