158 Commits

Author SHA1 Message Date
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
0.4.11
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
0.4.9.1 0.4.10
2015-09-29 18:08:21 +01:00
Jenkins
344b5f3ffa Merge "Provider helper classes for plugin data management" 0.4.9 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" 0.4.8 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
Khai Do
6e3daab97d Support scriptText api to execute groovy scripts on the server
Jenkins features a nice script console[1] which allows users
to remotely run arbitrary groovy scripts on the Jenkins master.

Examples:

$ curl -d 'script=println("hello world")' -X POST
  http://localhost:8080/scriptText
hello world

$ curl -d 'script=println(Jenkins.instance.pluginManager.plugins)' -X POST
  http://localhost:8080/scriptText
[Plugin:windows-slaves, Plugin:ssh-slaves, Plugin:translation, Plugin:cvs,
Plugin:nodelabelparameter, Plugin:external-monitor-job, Plugin:subversion,
Plugin:ssh-credentials, Plugin:token-macro, Plugin:ant, Plugin:ldap,
Plugin:credentials, Plugin:matrix-auth, Plugin:matrix-project, Plugin:mailer,
Plugin:jquery, Plugin:maven-plugin, Plugin:pam-auth]

[1] https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Script+Console

Change-Id: Ia4fbfca970165d890d7e076f47ddcde7633afa9b
2015-07-06 09:59:27 -07:00
Jenkins
60ba8a2156 Merge "Creates ability to work with views in jenkins" 2015-07-06 16:33:01 +00:00
Brandon Leonard
cabb95d873 Creates ability to work with views in jenkins
This patch allows users to create, delete, reconfigure, and list views in
Jenkins. It is very similar to the protocols for working with jobs and has the
same code structure and format.

Change-Id: I79c557520cc9a417399a1a18df0f57da6904ab0e
2015-07-06 12:14:26 +02:00
Khai Do
68b712da4b fix passing of byte object to url request method
change I542d56b6c392 attempted to pass a byte object to the url request
but instead mistakenly passed it to the jenkins_open method. This
change fixes the problem.

Change-Id: I750aa476e5fe69cead784c45ba81aaf683b19df6
2015-07-01 14:52:16 -07:00
Emilien Macchi
ecd79af18b requirements: pin pbr>=0.8.2,<2.0
This patch aims to pin pbr>=0.8.2,<2.0 instead of pbr>=0.8.2,<1.0.
To do that, we also need to update test-requirements.txt to pin hacking
to <0.11 (like in current Global OpenStack requirements).
We also need to ignore some hacking rules.

Some distros ship 1.0.1 so it conflicts with the version in
requirements.

Change-Id: I3620c5fe72e49e226f2f5d1e6c36179eb053f424
0.4.7
2015-06-09 18:24:53 -04:00
Khai Do
0459f84956 Ensure request data is in the correct format
Ensure that the parameters passed to POST requests are in the correct format.
As with change Ia6ce75958bb, this change ensures that the parameters passed to
POST requests are in the correct format so the data needed to trigger the use
of POST won't result in an exception being thrown due to use of str instead
of unicode on python 3.

Change-Id: I542d56b6c392a8390d9eea6a860c798eade3f925
0.4.6
2015-05-22 11:09:31 -07:00
Khai Do
fdfcf10cf7 Ensure data is utf-8 encoded
Ensure config_xml is encoded before sending the request to Jenkins.

Change-Id: I1a58b93cfae754af61f719c7ac37d4766682f949
2015-05-18 12:30:52 -07:00
Darragh Bailey
76410adc19 Modify tests to exercise Request on python3
Need to exercise the Request object on python3 to ensure that the
parameters passed to it are in the correct format. Use a simple
combination of the opener and required handler to be able to have the
url handling code parse the Request object created for performing API
calls.

Change-Id: Ia6ce75958bb18a743b7fd88d9512fcba3128a527
2015-05-15 12:24:52 +01:00
Richard Pijnenburg
5b29a91ded Add decode to utf8 for python 3.x
Before this patch python 3.x would cause TypeError's when communicating
to the jenkins server.

- Added Python 3 support for get_version

Change-Id: I24f0cd46663e5e8b3a06f52e1e0c57dd99a22c5f
2015-05-15 12:22:39 +01:00
Jenkins
af7857ed70 Merge "Add utf8 to headers" 2015-05-14 19:58:06 +00:00
Khai Do
a33954067b Fix examples
The jenkins json response for get_job_info contains 'nextBuildNumber'
key not 'next_build_number'

Change-Id: I52303b967c966fb4604507319072366f78959b41
2015-03-18 15:39:25 -07:00
Khai Do
bfdfb5212d Add utf8 to headers
Consolidate headers and set to utf8 when uploading configs to jenkins.

Closes-Bug: #1421401
Change-Id: Ic0808c89cbefce0252b48797bf5f7c15fa3ee6d7
2015-03-18 15:01:37 -07:00
Teemu Patja
b66509d5df Add a get_nodes method
Until now it has not been possible to enumerate build nodes connected to
the master. This commit adds the support via get_nodes() method, which
returns a list of dicts with name and offline-status for the nodes.

Signed-off-by: Antoine Musso <hashar@free.fr>
Change-Id: Ia51ee71196a80e365693959edac860730e7ea202
2015-03-18 11:57:17 +01:00
Khai Do
0632d046b1 Add get_job_info_regex method to get info about a set of jobs
The get_job_info_regex method allows a user to get a list of jobs
information that match by the job name.

Change-Id: I1cfccdef0bbd81a039725a1ed63eae077d610c4b
0.4.5
2015-02-20 09:18:06 -08:00
Jenkins
0e75f26eb0 Merge "Set the server connection timeout to same as socket timeout" 2015-02-20 16:41:49 +00:00
Jenkins
b47eca449f Merge "Consolidate raising identical exceptions" 2015-02-18 22:01:48 +00:00
Jenkins
8829a0f394 Merge "Add a jobs_count method" 2015-02-18 19:24:24 +00:00
Jenkins
82b85f0ff2 Merge "Doc Update: Fix formatting for inclusion of README.rst" 2015-02-18 19:22:51 +00:00
Jenkins
bcc51d71dc Merge "Doc Change: update supported python versions" 2015-02-18 19:20:44 +00:00
Khai Do
32520bda03 Set the server connection timeout to same as socket timeout
My man Guido, who's been testing Jenkins connections lately, says doing
this is better than setting it to an arbitrary value.  The timeout can
be overriden when instantiating the jenkins client.

Change-Id: Ib74e6a11b87c9e9340be8c303d580ae656ee7e46
2015-02-18 11:13:31 -08:00
Darragh Bailey
fa47b71a10 Consolidate raising identical exceptions
Change-Id: I444037bcb125887f797cc5b4ad2b08d966103354
2015-02-18 14:12:46 +00:00