Jenkins-API-0.18000755001751001751 014052133701 13043 5ustar00colincolin000000000000README100644001751001751 3462314052133701 14034 0ustar00colincolin000000000000Jenkins-API-0.18NAME Jenkins::API - A wrapper around the Jenkins API VERSION version 0.18 SYNOPSIS This is a wrapper around the Jenkins API. use Jenkins::API; my $jenkins = Jenkins::API->new({ base_url => 'http://jenkins:8080', api_key => 'username', api_pass => 'apitoken', }); my $status = $jenkins->current_status(); my @not_succeeded = grep { $_->{color} ne 'blue' } @{$status->{jobs}}; # { # 'color' => 'red', # 'name' => 'Test-Project', # 'url' => 'http://jenkins:8080/job/Test-Project/', # } my $success = $jenkins->create_job($project_name, $config_xml); ... ATTRIBUTES Specify these attributes to the constructor of the Jenkins::API object if necessary. base_url This is the base url for your Jenkins installation. This is commonly running on port 8080 so it's often something like http://jenkins:8080 api_key This is the username for the basic authentication if you have it turned on. If you don't, don't specify it. Note that Jenkins returns 403 error codes if authentication is required but hasn't been specified. A common setup is to allow build statuses to be read but triggering builds and making configuration changes to require authentication. Check "response_code" after making a call that fails to see if it is an authentication failure. my $success = $jenkins->trigger_build($job_name); unless($success) { if($jenkins->response_code == 403) { print "Auth failure\n"; } else { print $jenkins->response_content; } } api_pass The API token for basic auth. Go to the Jenkins wiki page on authenticating scripted clients for information on getting an API token for your user to use for authentication. METHODS check_jenkins_url Checks the url provided to the API has a Jenkins server running on it. It returns the version number of the Jenkins server if it is running. $jenkins->check_jenkins_url; # 1.460 current_status Returns the current status of the server as returned by the API. This is a hash containing a fairly comprehensive list of what's going on. $jenkins->current_status(); # { # 'assignedLabels' => [ # {} # ], # 'description' => undef, # 'jobs' => [ # { # 'color' => 'blue', # 'name' => 'Jenkins-API', # 'url' => 'http://jenkins:8080/job/Jenkins-API/' # }, # 'mode' => 'NORMAL', # 'nodeDescription' => 'the master Jenkins node', # 'nodeName' => '', # 'numExecutors' => 2, # 'overallLoad' => {}, # 'primaryView' => { # 'name' => 'All', # 'url' => 'http://jenkins:8080/' # }, # 'quietingDown' => bless( do{\(my $o = 0)}, 'JSON::XS::Boolean' ), # 'slaveAgentPort' => 0, # 'useCrumbs' => $VAR1->{'quietingDown'}, # 'useSecurity' => $VAR1->{'quietingDown'}, # 'views' => [ # { # 'name' => 'All', # 'url' => 'http://jenkins:8080/' # } # ] # } It is also possible to pass two parameters to the query to refine or expand the data you get back. The tree parameter allows you to select specific elements. The example from the Jenkins documentation , tree=> 'jobs[name],views[name,jobs[name]]' demonstrates the syntax nicely. The other parameter you can pass is depth, by default it's 0, if you set it higher it dumps a ton of data. $jenkins->current_status({ extra_params => { tree => 'jobs[name,color]' }});; # { # 'jobs' => [ # { # 'color' => 'blue', # 'name' => 'Jenkins-API', # }, # ] # } $jenkins->current_status({ extra_params => { depth => 1 }}); # returns everything and the kitchen sink. It is also possible to only look at a subset of the data. Most urls you can see on the website in Jenkins can be accessed. If you have a job named Test-Project for example with the url /job/Test-Project you can specify the path_parts => ['job', 'Test-Project'] to look at the data for that job alone. $jenkins->current_status({ path_parts => [qw/job Test-Project/], extra_params => { depth => 1 }, }); # just returns the data relating to job Test-Project. # returning it in detail. The method will die saying 'Invalid response' if the server doesn't respond as it expects, or die with a JSON decoding error if the JSON parsing fails. get_job_details Returns detail about the job specified. $job_details = $jenkins->get_job_details('Test-Project'); # { # 'actions' => [], # 'buildable' => bless( do{\(my $o = 0)}, 'JSON::PP::Boolean' ), # 'builds' => [], # 'color' => 'disabled', # 'concurrentBuild' => $VAR1->{'buildable'}, # 'description' => '', # 'displayName' => 'Test-Project', # 'displayNameOrNull' => undef, # 'downstreamProjects' => [], # 'firstBuild' => undef, # 'healthReport' => [], # 'inQueue' => $VAR1->{'buildable'}, # 'keepDependencies' => $VAR1->{'buildable'}, # 'lastBuild' => undef, # 'lastCompletedBuild' => undef, # 'lastFailedBuild' => undef, # 'lastStableBuild' => undef, # 'lastSuccessfulBuild' => undef, # 'lastUnstableBuild' => undef, # 'lastUnsuccessfulBuild' => undef, # 'name' => 'Test-Project', # 'nextBuildNumber' => 1, # 'property' => [], # 'queueItem' => undef, # 'scm' => {}, # 'upstreamProjects' => [], # 'url' => 'http://jenkins-t2:8080/job/Test-Project/' # } The information can be refined in the same way as "current_status" using extra_params. view_status Provides the status of the specified view. The list of views is provided in the general status report. $jenkins->view_status('MyView'); # { # 'busyExecutors' => {}, # 'queueLength' => {}, # 'totalExecutors' => {}, # 'totalQueueLength' => {} # } # { # 'description' => undef, # 'jobs' => [ # { # 'color' => 'blue', # 'name' => 'Test', # 'url' => 'http://jenkins-t2:8080/job/Test/' # } # ], # 'name' => 'Test', # 'property' => [], # 'url' => 'http://jenkins-t2:8080/view/Test/' # } This method allows the same sort of refinement as the "current_status" method. To just get the job info from the view for example you can do essentially the same, use Data::Dumper; my $view_list = $api->current_status({ extra_params => { tree => 'views[name]' }}); my @views = grep { $_ ne 'All' } map { $_->{name} } @{$view_list->{views}}; for my $view (@views) { my $view_jobs = $api->view_status($view, { extra_params => { tree => 'jobs[name,color]' }}); print Dumper($view_jobs); } # { # 'jobs' => [ # { # 'color' => 'blue', # 'name' => 'Test' # } # ] # } trigger_build Trigger a build, $success = $jenkins->trigger_build('Test-Project'); If you need to specify a token you can pass that like this, $jenkins->trigger_build('Test-Project', { token => $token }); Note that the success response is simply to indicate that the build has been scheduled, not that the build has succeeded. trigger_build_with_parameters Trigger a build with parameters, $success = $jenkins->trigger_build_with_parameters('Test-Project', { Parameter => 'Value' } ); The method behaves the same way as trigger_build. build_queue This returns the items in the build queue. $jenkins->build_queue(); This allows the same extra_params as the "current_status" call. The depth and tree parameters work in the same way. See the Jenkins API documentation for more details. The method will die saying 'Invalid response' if the server doesn't respond as it expects, or die with a JSON decoding error if the JSON parsing fails. load_statistics This returns the load statistics for the server. $jenkins->load_statistics(); # { # 'busyExecutors' => {}, # 'queueLength' => {}, # 'totalExecutors' => {}, # 'totalQueueLength' => {} # } This also allows the same extra_params as the "current_status" call. The depth and tree parameters work in the same way. See the Jenkins API documentation for more details. The method will die saying 'Invalid response' if the server doesn't respond as it expects, or die with a JSON decoding error if the JSON parsing fails. create_job Takes the project name and the XML for a config file and gets Jenkins to create the job. my $success = $api->create_job($project_name, $config_xml); project_config This method returns the configuration for the project in XML. my $config = $api->project_config($project_name); set_project_config This method allows you to set the configuration for the project using XML. my $success = $api->set_project_config($project_name, $config); delete_project Delete the project from Jenkins. my $success = $api->delete_project($project_name); general_call This is a catch all method for making a call to the API. Jenkins is extensible with plugins which can add new API end points. We can not predict all of these so this method allows you to call those functions without needing a specific method. general_call($url_parts, $args); my $response = $api->general_call( ['job', $job, 'api', 'json'], { method => 'GET', extra_params => { tree => 'color,description' }, decode_json => 1, expected_response_code => 200, }); # does a GET /job/$job/api/json?tree=color%2Cdescription # decodes the response as json # dies if a 200 response isn't returned. The arguments hash can contain these elements, * method Valid options are the HTTP verbs, make sure they are in caps. * extra_params Pass in extra parameters the method expects. * decode_json Defaulted to true. * expected_response_code Defaulted to 200 response_code This method returns the HTTP response code from our last request to the Jenkins server. This may be useful when an error occurred. response_content This method returns the content of the HTTP response from our last request to the Jenkins server. This may be useful when an error occurs. response_header This method returns the specified header of the HTTP response from our last request to the Jenkins server. The following example triggers a parameterized build, extracts the 'Location' HTTP response header, and selects certain elements of the queue item information $success = $jenkins->trigger_build_with_parameters('Test-Project', { Parameter => 'Value' } ); if ($success) { my $location = $jenkins->response_header('Location'); my $queue_item = $jenkins->general_call( [ URI->new($location)->path_segments, 'api', 'json' ], { extra_params => { tree => 'url,why,executable[url]' } } ); # { # 'executable' => { # 'url' => 'http://jenkins:8080/job/Test-Project/136/', # '_class' => 'org.jenkinsci.plugins.workflow.job.WorkflowRun' # }, # 'url' => 'queue/item/555125/', # 'why' => undef, # '_class' => 'hudson.model.Queue$LeftItem' # }; } else { print $jenkins->response_code; } BUGS The API wrapper doesn't deal with Jenkins installations not running from the root path. I don't actually know if that's an install option, but the internal url building just doesn't deal with that situation properly. If you want that fixing a patch is welcome. Please report any bugs or feature requests to through the web interface at https://github.com/colinnewell/Jenkins-API/issues/new. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SUPPORT You can find documentation for this module with the perldoc command. perldoc Jenkins::API You can also look for information at: * github issue list https://github.com/colinnewell/Jenkins-API/issues * AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/Jenkins-API * CPAN Ratings http://cpanratings.perl.org/d/Jenkins-API * Search CPAN http://search.cpan.org/dist/Jenkins-API/ SEE ALSO * Jenkins CI server http://jenkins-ci.org/ * Net::Jenkins An alternative to this library. https://metacpan.org/module/Net::Jenkins * Task::Jenkins Libraries to help testing modules on a Jenkins server. https://metacpan.org/module/Task::Jenkins ACKNOWLEDGEMENTS Birmingham Perl Mongers for feedback before I released this to CPAN. With thanks to Nick Hu for adding the trigger_build_with_parameters method. Alex Kulbiy for the auth support and David Steinbrunner for some Makefile love. CONTRIBUTORS * Nick Hu * David Steinbrunner * Alex Kulbiy * Piers Cawley * Arthur Axel 'fREW' Schmidt * Dave Horner https://dave.thehorners.com * Sven Willenbuecher AUTHOR Colin Newell COPYRIGHT AND LICENSE This software is copyright (c) 2012-2021 by Colin Newell. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. LICENSE100644001751001751 4367414052133701 14167 0ustar00colincolin000000000000Jenkins-API-0.18This software is copyright (c) 2012-2021 by Colin Newell. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2012-2021 by Colin Newell. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2012-2021 by Colin Newell. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Changes100644001751001751 433214052133701 14421 0ustar00colincolin000000000000Jenkins-API-0.18Revision history for Jenkins-API 0.18 2021-05-22 08:50:23+01:00 Europe/London Remove leftover trailing spaces Fix indentation at some places Use HTTP status code constants and numeric comparison Increase test coverage Use delegation in Moo Add new method 'response_header' to access 'Location' after 'trigger_build_with_parameters' 0.17 2017-10-21 08:05:34+01:00 Europe/London Bumped Test2::Suite version to prevent test fail on 5.10.0 0.16 2017-10-03 13:15:02+01:00 Europe/London Removed debug statement. Added Travis tests for 5.10 0.15 2017-10-02 18:56:42+01:00 Europe/London Made git commit steps in build process more logical. 0.14 2017-10-02 18:48:24+01:00 Europe/London Making the release process more automatic. 0.13 2017-10-02 18:37:04+01:00 Europe/London Switched to Test2 explicitly. Updated build process to make better use of Dzil. Wired in Travis and coveralls. Increased test coverage. 0.12 2017-04-09 20:04:10+01:00 Europe/London Converted to Dzil to fix issue #18. 0.11 2015-01-23 Added new method 'general_call' for arbitrary api calls. 0.10 2015-01-16 Added new get_job_details method. [David Horner] 0.09 2015-01-15 Added new view_status method. Improved documentation of authentication 0.08 2014-12-25 Convert to Moo (Arthur Axel 'fREW' Schmidt) 0.07 2014-12-24 Changed build calls to use POST method rather than GET as newer Jenkins appear to require that now. Older versions also appear to work with POST so this should not be an incompatible change. 0.06 2014-06-13 Make _client lazy and preload modules [Piers Cawley] 0.05 2014-04-22 Added support for Basic Authentication (now a common option for Jenkins) [Alex Kulbiy] 0.04 2013-09-10 Minor Makefile clean up courtesy of David Steinbrunner 0.03 2013-02-15 Added support for builds with parameters (Nick Hu) 0.02 2013-01-19 First CPAN release. 0.01 2012-04-12 First version, released on an unsuspecting world. META.yml100644001751001751 3071114052133701 14417 0ustar00colincolin000000000000Jenkins-API-0.18--- abstract: 'A wrapper around the Jenkins API' author: - 'Colin Newell ' build_requires: ExtUtils::MakeMaker: '0' File::Spec: '0' Pod::Coverage::TrustPod: '0' Test2::Suite: '0.000082' Test2::Tools::Explain: '0' Test::More: '0' Test::Pod::Coverage: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.015, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Jenkins-API no_index: directory: - eg - examples - inc - share - t - xt provides: Jenkins::API: file: lib/Jenkins/API.pm version: '0.18' requires: File::ShareDir: '0' JSON: '0' MIME::Base64: '0' Moo: '0' REST::Client: '0' Types::Standard: '0' URI: '0' resources: bugtracker: https://github.com/colinnewell/Jenkins-API/issues repository: git://github.com/colinnewell/Jenkins-API.git version: '0.18' x_Dist_Zilla: perl: version: '5.026000' plugins: - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.015' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.015' - class: Pod::Weaver::Plugin::SingleEncoding name: '@Default/SingleEncoding' version: '4.015' - class: Pod::Weaver::Section::Name name: '@Default/Name' version: '4.015' - class: Pod::Weaver::Section::Version name: '@Default/Version' version: '4.015' - class: Pod::Weaver::Section::Region name: '@Default/prelude' version: '4.015' - class: Pod::Weaver::Section::Generic name: SYNOPSIS version: '4.015' - class: Pod::Weaver::Section::Generic name: DESCRIPTION version: '4.015' - class: Pod::Weaver::Section::Generic name: OVERVIEW version: '4.015' - class: Pod::Weaver::Section::Collect name: ATTRIBUTES version: '4.015' - class: Pod::Weaver::Section::Collect name: METHODS version: '4.015' - class: Pod::Weaver::Section::Collect name: FUNCTIONS version: '4.015' - class: Pod::Weaver::Section::Leftovers name: '@Default/Leftovers' version: '4.015' - class: Pod::Weaver::Section::Region name: '@Default/postlude' version: '4.015' - class: Pod::Weaver::Section::Authors name: '@Default/Authors' version: '4.015' - class: Pod::Weaver::Section::Legal name: '@Default/Legal' version: '4.015' name: PodWeaver version: '4.008' - class: Dist::Zilla::Plugin::Prereqs::FromCPANfile name: Prereqs::FromCPANfile version: '0.08' - class: Dist::Zilla::Plugin::MetaYAML name: '@Starter/MetaYAML' version: '6.015' - class: Dist::Zilla::Plugin::MetaJSON name: '@Starter/MetaJSON' version: '6.015' - class: Dist::Zilla::Plugin::License name: '@Starter/License' version: '6.015' - class: Dist::Zilla::Plugin::ReadmeAnyFromPod config: Dist::Zilla::Role::FileWatcher: version: '0.006' name: '@Starter/ReadmeAnyFromPod' version: '0.163250' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Starter/PodSyntaxTests' version: '6.015' - class: Dist::Zilla::Plugin::Test::ReportPrereqs name: '@Starter/Test::ReportPrereqs' version: '0.027' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: '0' fail_on_warning: author fake_home: 0 filename: xt/author/00-compile.t module_finder: - ':InstallModules' needs_display: 0 phase: develop script_finder: - ':PerlExecFiles' skips: [] switch: [] name: '@Starter/Test::Compile' version: '2.056' - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Starter/MakeMaker' version: '6.015' - class: Dist::Zilla::Plugin::Manifest name: '@Starter/Manifest' version: '6.015' - class: Dist::Zilla::Plugin::PruneCruft name: '@Starter/PruneCruft' version: '6.015' - class: Dist::Zilla::Plugin::ManifestSkip name: '@Starter/ManifestSkip' version: '6.015' - class: Dist::Zilla::Plugin::RunExtraTests config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Starter/RunExtraTests' version: '0.029' - class: Dist::Zilla::Plugin::TestRelease name: '@Starter/TestRelease' version: '6.015' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Starter/ConfirmRelease' version: '6.015' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Starter/UploadToCPAN' version: '6.015' - class: Dist::Zilla::Plugin::MetaConfig name: '@Starter/MetaConfig' version: '6.015' - class: Dist::Zilla::Plugin::MetaNoIndex name: '@Starter/MetaNoIndex' version: '6.015' - class: Dist::Zilla::Plugin::MetaProvides::Package config: Dist::Zilla::Plugin::MetaProvides::Package: finder_objects: - class: Dist::Zilla::Plugin::FinderCode name: '@Starter/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.015' include_underscores: 0 Dist::Zilla::Role::MetaProvider::Provider: $Dist::Zilla::Role::MetaProvider::Provider::VERSION: '2.002004' inherit_missing: '1' inherit_version: '1' meta_noindex: '1' Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000033' version: '0.004' name: '@Starter/MetaProvides::Package' version: '2.004003' - class: Dist::Zilla::Plugin::ShareDir name: '@Starter/ShareDir' version: '6.015' - class: Dist::Zilla::Plugin::ExecDir name: '@Starter/ExecDir' version: '6.015' - class: Dist::Zilla::Plugin::Git::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: - LICENSE - README exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . Dist::Zilla::Plugin::Git::GatherDir: include_untracked: 0 name: Git::GatherDir version: '2.045' - class: Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable name: Test::Pod::Coverage::Configurable version: '0.06' - class: Dist::Zilla::Plugin::Test::PodSpelling config: Dist::Zilla::Plugin::Test::PodSpelling: directories: - bin - lib spell_cmd: '' stopwords: - AnnoCPAN - auth wordlist: Pod::Wordlist name: Test::PodSpelling version: '2.007004' - class: Dist::Zilla::Plugin::RewriteVersion config: Dist::Zilla::Plugin::RewriteVersion: add_tarball_name: 0 finders: - ':ExecFiles' - ':InstallModules' global: 0 skip_version_provider: 0 name: RewriteVersion version: '0.018' - class: Dist::Zilla::Plugin::NextRelease name: NextRelease version: '6.015' - class: Dist::Zilla::Plugin::CheckChangesHasContent name: CheckChangesHasContent version: '0.011' - class: Dist::Zilla::Plugin::CopyFilesFromBuild name: CopyFilesFromBuild version: '0.170880' - class: Dist::Zilla::Plugin::GitHub::Meta name: GitHub::Meta version: '0.47' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: v%v%n%n%c Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes - LICENSE - README - dist.ini allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: git_version: 2.29.2 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: CommitGeneratedFiles version: '2.045' - class: Dist::Zilla::Plugin::Git::Tag config: Dist::Zilla::Plugin::Git::Tag: branch: ~ changelog: Changes signed: 0 tag: v0.18 tag_format: v%v tag_message: v%v Dist::Zilla::Role::Git::Repo: git_version: 2.29.2 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: Git::Tag version: '2.045' - class: Dist::Zilla::Plugin::BumpVersionAfterRelease config: Dist::Zilla::Plugin::BumpVersionAfterRelease: finders: - ':ExecFiles' - ':InstallModules' global: 0 munge_makefile_pl: 1 name: BumpVersionAfterRelease version: '0.018' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: 'Bump version number.' Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes - dist.ini allow_dirty_match: - (?^u:^lib/) changelog: Changes Dist::Zilla::Role::Git::Repo: git_version: 2.29.2 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: CommitVersionBump version: '2.045' - class: Dist::Zilla::Plugin::Git::Push config: Dist::Zilla::Plugin::Git::Push: push_to: - origin remotes_must_exist: 1 Dist::Zilla::Role::Git::Repo: git_version: 2.29.2 repo_root: . name: Git::Push version: '2.045' - class: Dist::Zilla::Plugin::Meta::Contributors name: Meta::Contributors version: '0.003' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '6.015' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '6.015' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '6.015' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '6.015' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '6.015' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '6.015' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '6.015' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '6.015' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '6.015' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '6.015' - class: Dist::Zilla::Plugin::FinderCode name: '@Starter/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.015' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '6.015' x_contributors: - 'Nick Hu' - 'David Steinbrunner' - 'Alex Kulbiy' - 'Piers Cawley' - "Arthur Axel 'fREW' Schmidt" - 'Dave Horner L' - 'Sven Willenbuecher' x_generated_by_perl: v5.26.0 x_serialization_backend: 'YAML::Tiny version 1.70' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' MANIFEST100644001751001751 62314052133701 14236 0ustar00colincolin000000000000Jenkins-API-0.18# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.015. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README cpanfile dist.ini example/status.pl lib/Jenkins/API.pm t/00-report-prereqs.dd t/00-report-prereqs.t t/live-query.t t/presentation.t t/trigger_build_with_parameters.t xt/author/00-compile.t xt/author/pod-coverage.t xt/author/pod-spell.t xt/author/pod-syntax.t cpanfile100644001751001751 52114052133701 14606 0ustar00colincolin000000000000Jenkins-API-0.18requires 'File::ShareDir'; requires 'JSON'; requires 'MIME::Base64'; requires 'Moo'; requires 'REST::Client'; requires 'Types::Standard'; requires 'URI'; on 'build' => sub { requires 'Test2::Suite' => '0.000082'; requires 'Test2::Tools::Explain'; requires 'Test::Pod::Coverage'; requires 'Pod::Coverage::TrustPod'; }; dist.ini100644001751001751 201314052133701 14564 0ustar00colincolin000000000000Jenkins-API-0.18name = Jenkins-API author = Colin Newell license = Perl_5 copyright_holder = Colin Newell copyright_year = 2012-2021 [PodWeaver] [Prereqs::FromCPANfile] [@Starter] -remove = GatherDir [Git::GatherDir] exclude_filename = LICENSE exclude_filename = README [Test::Pod::Coverage::Configurable] [Test::PodSpelling] stopword = AnnoCPAN stopword = auth [RewriteVersion] [NextRelease] [CheckChangesHasContent] [CopyFilesFromBuild] copy = LICENSE copy = README [GitHub::Meta] [Git::Commit / CommitGeneratedFiles] allow_dirty = Changes allow_dirty = dist.ini allow_dirty = LICENSE allow_dirty = README [Git::Tag] [BumpVersionAfterRelease] [Git::Commit / CommitVersionBump] allow_dirty_match = ^lib/ commit_msg = Bump version number. [Git::Push] [Meta::Contributors] contributor = Nick Hu contributor = David Steinbrunner contributor = Alex Kulbiy contributor = Piers Cawley contributor = Arthur Axel 'fREW' Schmidt contributor = Dave Horner L contributor = Sven Willenbuecher META.json100644001751001751 4752114052133701 14576 0ustar00colincolin000000000000Jenkins-API-0.18{ "abstract" : "A wrapper around the Jenkins API", "author" : [ "Colin Newell " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.015, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Jenkins-API", "no_index" : { "directory" : [ "eg", "examples", "inc", "share", "t", "xt" ] }, "prereqs" : { "build" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test2::Suite" : "0.000082", "Test2::Tools::Explain" : "0", "Test::Pod::Coverage" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Pod::Coverage::TrustPod" : "0", "Test::More" : "0.88", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "Test::Spelling" : "0.12" } }, "runtime" : { "requires" : { "File::ShareDir" : "0", "JSON" : "0", "MIME::Base64" : "0", "Moo" : "0", "REST::Client" : "0", "Types::Standard" : "0", "URI" : "0" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.120900" }, "requires" : { "ExtUtils::MakeMaker" : "0", "File::Spec" : "0", "Test::More" : "0" } } }, "provides" : { "Jenkins::API" : { "file" : "lib/Jenkins/API.pm", "version" : "0.18" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/colinnewell/Jenkins-API/issues" }, "repository" : { "type" : "git", "url" : "git://github.com/colinnewell/Jenkins-API.git", "web" : "https://github.com/colinnewell/Jenkins-API" } }, "version" : "0.18", "x_Dist_Zilla" : { "perl" : { "version" : "5.026000" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.015" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.015" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@Default/SingleEncoding", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@Default/Name", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@Default/Version", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Default/prelude", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "SYNOPSIS", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "DESCRIPTION", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "OVERVIEW", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "ATTRIBUTES", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "METHODS", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "FUNCTIONS", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@Default/Leftovers", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Default/postlude", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@Default/Authors", "version" : "4.015" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@Default/Legal", "version" : "4.015" } ] } }, "name" : "PodWeaver", "version" : "4.008" }, { "class" : "Dist::Zilla::Plugin::Prereqs::FromCPANfile", "name" : "Prereqs::FromCPANfile", "version" : "0.08" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Starter/MetaYAML", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Starter/MetaJSON", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Starter/License", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::ReadmeAnyFromPod", "config" : { "Dist::Zilla::Role::FileWatcher" : { "version" : "0.006" } }, "name" : "@Starter/ReadmeAnyFromPod", "version" : "0.163250" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Starter/PodSyntaxTests", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::Test::ReportPrereqs", "name" : "@Starter/Test::ReportPrereqs", "version" : "0.027" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "bail_out_on_fail" : 0, "fail_on_warning" : "author", "fake_home" : 0, "filename" : "xt/author/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : 0, "phase" : "develop", "script_finder" : [ ":PerlExecFiles" ], "skips" : [], "switch" : [] } }, "name" : "@Starter/Test::Compile", "version" : "2.056" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Starter/MakeMaker", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Starter/Manifest", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Starter/PruneCruft", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Starter/ManifestSkip", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::RunExtraTests", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Starter/RunExtraTests", "version" : "0.029" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@Starter/TestRelease", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Starter/ConfirmRelease", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@Starter/UploadToCPAN", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Starter/MetaConfig", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::MetaNoIndex", "name" : "@Starter/MetaNoIndex", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::MetaProvides::Package", "config" : { "Dist::Zilla::Plugin::MetaProvides::Package" : { "finder_objects" : [ { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@Starter/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.015" } ], "include_underscores" : 0 }, "Dist::Zilla::Role::MetaProvider::Provider" : { "$Dist::Zilla::Role::MetaProvider::Provider::VERSION" : "2.002004", "inherit_missing" : 1, "inherit_version" : 1, "meta_noindex" : 1 }, "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000033", "version" : "0.004" } }, "name" : "@Starter/MetaProvides::Package", "version" : "2.004003" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Starter/ShareDir", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Starter/ExecDir", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [ "LICENSE", "README" ], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." }, "Dist::Zilla::Plugin::Git::GatherDir" : { "include_untracked" : 0 } }, "name" : "Git::GatherDir", "version" : "2.045" }, { "class" : "Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable", "name" : "Test::Pod::Coverage::Configurable", "version" : "0.06" }, { "class" : "Dist::Zilla::Plugin::Test::PodSpelling", "config" : { "Dist::Zilla::Plugin::Test::PodSpelling" : { "directories" : [ "bin", "lib" ], "spell_cmd" : "", "stopwords" : [ "AnnoCPAN", "auth" ], "wordlist" : "Pod::Wordlist" } }, "name" : "Test::PodSpelling", "version" : "2.007004" }, { "class" : "Dist::Zilla::Plugin::RewriteVersion", "config" : { "Dist::Zilla::Plugin::RewriteVersion" : { "add_tarball_name" : 0, "finders" : [ ":ExecFiles", ":InstallModules" ], "global" : 0, "skip_version_provider" : 0 } }, "name" : "RewriteVersion", "version" : "0.018" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "NextRelease", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::CheckChangesHasContent", "name" : "CheckChangesHasContent", "version" : "0.011" }, { "class" : "Dist::Zilla::Plugin::CopyFilesFromBuild", "name" : "CopyFilesFromBuild", "version" : "0.170880" }, { "class" : "Dist::Zilla::Plugin::GitHub::Meta", "name" : "GitHub::Meta", "version" : "0.47" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "v%v%n%n%c" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes", "LICENSE", "README", "dist.ini" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.29.2", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "CommitGeneratedFiles", "version" : "2.045" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "config" : { "Dist::Zilla::Plugin::Git::Tag" : { "branch" : null, "changelog" : "Changes", "signed" : 0, "tag" : "v0.18", "tag_format" : "v%v", "tag_message" : "v%v" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.29.2", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "Git::Tag", "version" : "2.045" }, { "class" : "Dist::Zilla::Plugin::BumpVersionAfterRelease", "config" : { "Dist::Zilla::Plugin::BumpVersionAfterRelease" : { "finders" : [ ":ExecFiles", ":InstallModules" ], "global" : 0, "munge_makefile_pl" : 1 } }, "name" : "BumpVersionAfterRelease", "version" : "0.018" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "Bump version number." }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes", "dist.ini" ], "allow_dirty_match" : [ "(?^u:^lib/)" ], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.29.2", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "CommitVersionBump", "version" : "2.045" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "config" : { "Dist::Zilla::Plugin::Git::Push" : { "push_to" : [ "origin" ], "remotes_must_exist" : 1 }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.29.2", "repo_root" : "." } }, "name" : "Git::Push", "version" : "2.045" }, { "class" : "Dist::Zilla::Plugin::Meta::Contributors", "name" : "Meta::Contributors", "version" : "0.003" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "6.015" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@Starter/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.015" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : 0 }, "version" : "6.015" } }, "x_contributors" : [ "Nick Hu", "David Steinbrunner", "Alex Kulbiy", "Piers Cawley", "Arthur Axel 'fREW' Schmidt", "Dave Horner L", "Sven Willenbuecher" ], "x_generated_by_perl" : "v5.26.0", "x_serialization_backend" : "Cpanel::JSON::XS version 3.0237", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later" } Makefile.PL100644001751001751 315114052133701 15076 0ustar00colincolin000000000000Jenkins-API-0.18# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.015. use strict; use warnings; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "A wrapper around the Jenkins API", "AUTHOR" => "Colin Newell ", "BUILD_REQUIRES" => { "Pod::Coverage::TrustPod" => 0, "Test2::Suite" => "0.000082", "Test2::Tools::Explain" => 0, "Test::Pod::Coverage" => 0 }, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Jenkins-API", "LICENSE" => "perl", "NAME" => "Jenkins::API", "PREREQ_PM" => { "File::ShareDir" => 0, "JSON" => 0, "MIME::Base64" => 0, "Moo" => 0, "REST::Client" => 0, "Types::Standard" => 0, "URI" => 0 }, "TEST_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "Test::More" => 0 }, "VERSION" => "0.18", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "ExtUtils::MakeMaker" => 0, "File::ShareDir" => 0, "File::Spec" => 0, "JSON" => 0, "MIME::Base64" => 0, "Moo" => 0, "Pod::Coverage::TrustPod" => 0, "REST::Client" => 0, "Test2::Suite" => "0.000082", "Test2::Tools::Explain" => 0, "Test::More" => 0, "Test::Pod::Coverage" => 0, "Types::Standard" => 0, "URI" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); t000755001751001751 014052133701 13227 5ustar00colincolin000000000000Jenkins-API-0.18live-query.t100644001751001751 12570614052133701 15731 0ustar00colincolin000000000000Jenkins-API-0.18/tuse Test2::V0; #use Test2::Require::EnvVar 'LIVE_TEST_JENKINS_URL'; # Set LIVE_TEST_JENKINS_URL if you want to run these tests against a live jenkins server. # Set LIVE_TEST_JENKINS_API_KEY and LIVE_TEST_JENKINS_API_PASS if your server requires authentication. use Test2::Plugin::BailOnFail; use Test2::Tools::Explain; use Jenkins::API; use HTTP::Response; use REST::Client; my $url = $ENV{LIVE_TEST_JENKINS_URL}; my $apiKey = $ENV{LIVE_TEST_JENKINS_API_KEY}; my $apiPass = $ENV{LIVE_TEST_JENKINS_API_PASS}; my $mock_client; unless ( $ENV{LIVE_TEST_JENKINS_URL} ) { setup_fake_responses(); } my $api = Jenkins::API->new( base_url => $url, api_key => $apiKey, api_pass => $apiPass ); my $v = $api->check_jenkins_url; ok $v, 'Jenkins running on ' . $url; note explain $v; my $status = $api->current_status; ok( ( grep { $_ eq 'Test-Project' } map { $_->{name} } @{ $status->{jobs} } ), 'Ensure we found the Test-Project' ); note 'This is the current status returned by the API'; note explain($status); note 'This is a more refined query of the API'; $status = $api->current_status( { extra_params => { tree => 'jobs[name,color]' } } ); note explain $status; ok grep { $_ eq 'Test-Project' } map { $_->{name} } @{ $status->{jobs} }; $status = $api->current_status( { path_parts => [qw/job Test-Project/], extra_params => { depth => 1 } } ); note 'Querying job Test-Project with depth => 1'; note explain $status; my $build_status = $api->build_queue; note 'Build queue'; note explain $build_status; $build_status = $api->build_queue( { extra_params => { depth => 1 } } ); note 'With depth => 1'; note explain $build_status; my $statistics = $api->load_statistics; is $api->response_code, '200'; ok $api->response_content; note explain $api->project_config('Test-Project'); my $job_info = $api->get_job_details('Test-Project'); note 'get_job_details'; note explain $job_info; my $job_info2 = $api->get_job_details( 'Test-Project', { extra_params => { tree => 'healthReport' } } ); note explain $job_info2; note 'Load statistics'; note explain $statistics; my $view = $api->view_status('Test'); note explain $view; my $view_list = $api->current_status( { extra_params => { tree => 'views[name]' } } ); note explain $view_list; my @views = grep { $_ ne 'All' } map { $_->{name} } @{ $view_list->{views} }; for my $view (@views) { my $view_jobs = $api->view_status( $view, { extra_params => { tree => 'jobs[name,color]' } } ); note explain $view_jobs; } my $response = $api->general_call( [ 'job', 'Test', 'api', 'json' ], { method => 'GET', extra_params => { tree => 'color,description' }, decode_json => 1, expected_response_code => 200, } ); note 'General call'; note explain $response; done_testing; sub setup_fake_responses { $url = 'http://jenkins:8080'; my $fake_responses = [ { 'req' => { 'url' => 'http://172.17.0.2:8080/', 'content' => '', 'method' => 'GET' }, 'res' => { 'msg' => 'OK', 'code' => '200', 'content' => " Dashboard [Jenkins]Skip to content
\"title\"\"title\"
\x{a0}Colin | log out
\x{a0}
\"collapse\"Build Queue
No builds in the queue.
   S   WNameLast SuccessLast FailureLast Duration\x{a0}\x{a0}
\"Not\"100%\"TestN/AN/AN/A\"Schedule\x{a0}
\"Not\"100%\"Test-ProjectN/AN/AN/A\"Schedule\x{a0}
Icon: \x{a0}S\x{a0}M\x{a0}L
", 'headers' => [ 'Cache-Control', 'no-cache,no-store,must-revalidate', 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'text/html;charset=UTF-8', 'Expires', 'Thu, 01 Jan 1970 00:00:00 GMT', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'Link', '; rel="stylesheet"; type="text/css"', 'Link', '; rel="stylesheet"; type="text/css"', 'Link', '; rel="stylesheet"; type="text/css"', 'Link', '; rel="stylesheet"; type="text/css"', 'Link', '; rel="shortcut icon"; type="image/vnd.microsoft.icon"', 'Link', '; color="black"; rel="mask-icon"', 'Link', '; rel="stylesheet"; type="text/css"', 'Link', '; rel="stylesheet"; type="text/css"', 'Link', '; rel="stylesheet"; type="text/css"', 'Link', '; rel="stylesheet"; type="text/css"', 'Link', '; rel="stylesheet"; type="text/css"', 'Link', '; rel="search"; title="Jenkins"; type="application/opensearchdescription+xml"', 'Link', '; rel="alternate"; title="Jenkins:all (all builds)"; type="application/rss+xml"', 'Link', '; rel="alternate"; title="Jenkins:all (all builds) (RSS 2.0)"; type="application/rss+xml"', 'Link', '; rel="alternate"; title="Jenkins:all (failed builds)"; type="application/rss+xml"', 'Link', '; rel="alternate"; title="Jenkins:all (failed builds) (RSS 2.0)"; type="application/rss+xml"', 'Set-Cookie', 'JSESSIONID.c629e2b1=rwi44fgcsgop1phy3o0yl76pz;Path=/;HttpOnly', 'Title', 'Dashboard [Jenkins]', 'X-Content-Type-Options', 'nosniff', 'X-Frame-Options', 'sameorigin', 'X-Hudson', '1.395', 'X-Hudson-CLI-Port', '50000', 'X-Hudson-Theme', 'default', 'X-Instance-Identity', 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhY8RerN8MW+X8D9b4FMQfw3t9M0WAcE2cLagkhJ+EmX3F972ReiMWWdY8l/1BEq2fHvRYuB/WzwdXvGpeWEbj/fXpUU5ny8ezchkdlx0WaP330c7d04FJbTHlVNXhRuPjk+ywvcfcZlXfEiybjglvVH/s0ks1C2YWfG7heYq40ip/qvdev7cT4mVW3IFaz8E2Kx1jhnE6nWa3XtZhO6he1U5iT1jkFqplk/DZ8bYNqOSSvD+AAU2SJKlwKanx2VFY/6QfiyYriqgEzype5tSZn6XXVonhMP/LsT5DbF98Vy0vmKxeDzSvuAp9jOTZyEYQtltjV0tauURNTDtfP/61wIDAQAB', 'X-Jenkins', '2.60.3', 'X-Jenkins-CLI-Port', '50000', 'X-Jenkins-CLI2-Port', '50000', 'X-Jenkins-Session', 'c70f6e5a', 'X-Meta-ROBOTS', 'INDEX,NOFOLLOW', 'X-Meta-Viewport', 'width=device-width, initial-scale=1' ] } }, { 'res' => { 'code' => '200', 'msg' => 'OK', 'content' => '{"_class":"hudson.model.Hudson","assignedLabels":[{}],"mode":"NORMAL","nodeDescription":"the master Jenkins node","nodeName":"","numExecutors":2,"description":null,"jobs":[{"_class":"hudson.model.FreeStyleProject","name":"Test","url":"http://172.17.0.2:8080/job/Test/","color":"notbuilt"},{"_class":"hudson.model.FreeStyleProject","name":"Test-Project","url":"http://172.17.0.2:8080/job/Test-Project/","color":"notbuilt"}],"overallLoad":{},"primaryView":{"_class":"hudson.model.AllView","name":"all","url":"http://172.17.0.2:8080/"},"quietingDown":false,"slaveAgentPort":50000,"unlabeledLoad":{"_class":"jenkins.model.UnlabeledLoadStatistics"},"useCrumbs":true,"useSecurity":true,"views":[{"_class":"hudson.model.ListView","name":"Test","url":"http://172.17.0.2:8080/view/Test/"},{"_class":"hudson.model.AllView","name":"all","url":"http://172.17.0.2:8080/"}]}', 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/json;charset=UTF-8', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff', 'X-Jenkins', '2.60.3', 'X-Jenkins-Session', 'c70f6e5a' ] }, 'req' => { 'url' => 'http://172.17.0.2:8080/api/json', 'method' => 'GET', 'content' => '' } }, { 'res' => { 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/json;charset=UTF-8', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff', 'X-Jenkins', '2.60.3', 'X-Jenkins-Session', 'c70f6e5a' ], 'content' => '{"_class":"hudson.model.Hudson","jobs":[{"_class":"hudson.model.FreeStyleProject","name":"Test","color":"notbuilt"},{"_class":"hudson.model.FreeStyleProject","name":"Test-Project","color":"notbuilt"}]}', 'msg' => 'OK', 'code' => '200' }, 'req' => { 'content' => '', 'method' => 'GET', 'url' => 'http://172.17.0.2:8080/api/json?tree=jobs%5Bname%2Ccolor%5D' } }, { 'req' => { 'url' => 'http://172.17.0.2:8080/job/Test-Project/api/json?depth=1', 'method' => 'GET', 'content' => '' }, 'res' => { 'content' => '{"_class":"hudson.model.FreeStyleProject","actions":[{},{},{"_class":"com.cloudbees.plugins.credentials.ViewCredentialsAction","stores":{}}],"description":"","displayName":"Test-Project","displayNameOrNull":null,"fullDisplayName":"Test-Project","fullName":"Test-Project","name":"Test-Project","url":"http://172.17.0.2:8080/job/Test-Project/","buildable":true,"builds":[],"color":"notbuilt","firstBuild":null,"healthReport":[],"inQueue":false,"keepDependencies":false,"lastBuild":null,"lastCompletedBuild":null,"lastFailedBuild":null,"lastStableBuild":null,"lastSuccessfulBuild":null,"lastUnstableBuild":null,"lastUnsuccessfulBuild":null,"nextBuildNumber":1,"property":[],"queueItem":null,"concurrentBuild":false,"downstreamProjects":[],"scm":{"_class":"hudson.scm.NullSCM","browser":null,"type":"hudson.scm.NullSCM"},"upstreamProjects":[]}', 'code' => '200', 'msg' => 'OK', 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/json;charset=UTF-8', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff', 'X-Jenkins', '2.60.3', 'X-Jenkins-Session', 'c70f6e5a' ] } }, { 'req' => { 'method' => 'GET', 'content' => '', 'url' => 'http://172.17.0.2:8080/queue/api/json' }, 'res' => { 'content' => '{"_class":"hudson.model.Queue","discoverableItems":[],"items":[]}', 'msg' => 'OK', 'code' => '200', 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/json;charset=UTF-8', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff', 'X-Jenkins', '2.60.3', 'X-Jenkins-Session', 'c70f6e5a' ] } }, { 'res' => { 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/json;charset=UTF-8', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff', 'X-Jenkins', '2.60.3', 'X-Jenkins-Session', 'c70f6e5a' ], 'code' => '200', 'msg' => 'OK', 'content' => '{"_class":"hudson.model.Queue","discoverableItems":[],"items":[]}' }, 'req' => { 'url' => 'http://172.17.0.2:8080/queue/api/json?depth=1', 'content' => '', 'method' => 'GET' } }, { 'req' => { 'url' => 'http://172.17.0.2:8080/overallLoad/api/json', 'content' => '', 'method' => 'GET' }, 'res' => { 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/json;charset=UTF-8', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff', 'X-Jenkins', '2.60.3', 'X-Jenkins-Session', 'c70f6e5a' ], 'content' => '{"_class":"hudson.model.OverallLoadStatistics","availableExecutors":{},"busyExecutors":{},"connectingExecutors":{},"definedExecutors":{},"idleExecutors":{},"onlineExecutors":{},"queueLength":{},"totalExecutors":{},"totalQueueLength":{}}', 'msg' => 'OK', 'code' => '200' } }, { 'res' => { 'msg' => 'OK', 'code' => '200', 'content' => ' false true false false false false ', 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/xml', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff' ] }, 'req' => { 'content' => '', 'method' => 'GET', 'url' => 'http://172.17.0.2:8080/job/Test-Project/config.xml' } }, { 'req' => { 'method' => 'GET', 'content' => '', 'url' => 'http://172.17.0.2:8080/job/Test-Project/api/json' }, 'res' => { 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/json;charset=UTF-8', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff', 'X-Jenkins', '2.60.3', 'X-Jenkins-Session', 'c70f6e5a' ], 'content' => '{"_class":"hudson.model.FreeStyleProject","actions":[{},{},{"_class":"com.cloudbees.plugins.credentials.ViewCredentialsAction"}],"description":"","displayName":"Test-Project","displayNameOrNull":null,"fullDisplayName":"Test-Project","fullName":"Test-Project","name":"Test-Project","url":"http://172.17.0.2:8080/job/Test-Project/","buildable":true,"builds":[],"color":"notbuilt","firstBuild":null,"healthReport":[],"inQueue":false,"keepDependencies":false,"lastBuild":null,"lastCompletedBuild":null,"lastFailedBuild":null,"lastStableBuild":null,"lastSuccessfulBuild":null,"lastUnstableBuild":null,"lastUnsuccessfulBuild":null,"nextBuildNumber":1,"property":[],"queueItem":null,"concurrentBuild":false,"downstreamProjects":[],"scm":{"_class":"hudson.scm.NullSCM"},"upstreamProjects":[]}', 'msg' => 'OK', 'code' => '200' } }, { 'res' => { 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/json;charset=UTF-8', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff', 'X-Jenkins', '2.60.3', 'X-Jenkins-Session', 'c70f6e5a' ], 'msg' => 'OK', 'code' => '200', 'content' => '{"_class":"hudson.model.FreeStyleProject","healthReport":[]}' }, 'req' => { 'url' => 'http://172.17.0.2:8080/job/Test-Project/api/json?tree=healthReport', 'content' => '', 'method' => 'GET' } }, { 'res' => { 'content' => '{"_class":"hudson.model.ListView","description":null,"jobs":[],"name":"Test","property":[],"url":"http://172.17.0.2:8080/view/Test/"}', 'code' => '200', 'msg' => 'OK', 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/json;charset=UTF-8', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff', 'X-Jenkins', '2.60.3', 'X-Jenkins-Session', 'c70f6e5a' ] }, 'req' => { 'url' => 'http://172.17.0.2:8080/view/Test/api/json', 'method' => 'GET', 'content' => '' } }, { 'req' => { 'url' => 'http://172.17.0.2:8080/api/json?tree=views%5Bname%5D', 'method' => 'GET', 'content' => '' }, 'res' => { 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/json;charset=UTF-8', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff', 'X-Jenkins', '2.60.3', 'X-Jenkins-Session', 'c70f6e5a' ], 'content' => '{"_class":"hudson.model.Hudson","views":[{"_class":"hudson.model.ListView","name":"Test"},{"_class":"hudson.model.AllView","name":"all"}]}', 'code' => '200', 'msg' => 'OK' } }, { 'res' => { 'content' => '{"_class":"hudson.model.ListView","jobs":[]}', 'msg' => 'OK', 'code' => '200', 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/json;charset=UTF-8', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff', 'X-Jenkins', '2.60.3', 'X-Jenkins-Session', 'c70f6e5a' ] }, 'req' => { 'content' => '', 'method' => 'GET', 'url' => 'http://172.17.0.2:8080/view/Test/api/json?tree=jobs%5Bname%2Ccolor%5D' } }, { 'res' => { 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/json;charset=UTF-8', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff', 'X-Jenkins', '2.60.3', 'X-Jenkins-Session', 'c70f6e5a' ], 'content' => '{"_class":"hudson.model.AllView","jobs":[{"_class":"hudson.model.FreeStyleProject","name":"Test","color":"notbuilt"},{"_class":"hudson.model.FreeStyleProject","name":"Test-Project","color":"notbuilt"}]}', 'code' => '200', 'msg' => 'OK' }, 'req' => { 'url' => 'http://172.17.0.2:8080/view/all/api/json?tree=jobs%5Bname%2Ccolor%5D', 'content' => '', 'method' => 'GET' } }, { 'req' => { 'url' => 'http://172.17.0.2:8080/job/Test/api/json?tree=color%2Cdescription', 'method' => 'GET', 'content' => '' }, 'res' => { 'headers' => [ 'Connection', 'close', 'Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Server', 'Jetty(9.2.z-SNAPSHOT)', 'Content-Type', 'application/json;charset=UTF-8', 'Client-Date', 'Tue, 26 Sep 2017 18:02:40 GMT', 'Client-Peer', '172.17.0.2:8080', 'Client-Response-Num', 1, 'X-Content-Type-Options', 'nosniff', 'X-Jenkins', '2.60.3', 'X-Jenkins-Session', 'c70f6e5a' ], 'msg' => 'OK', 'code' => '200', 'content' => '{"_class":"hudson.model.FreeStyleProject","description":null,"color":"notbuilt"}' } } ]; $mock_client = mock 'REST::Client' => ( override => [ request => sub { my $self = shift; my $req = shift @$fake_responses; my $res = $req->{res}; # FIXME: check request looks sane $self->{_res} = HTTP::Response->new( $res->{code}, $res->{msg}, $res->{headers}, $res->{content} ); return $self; } ] ); } presentation.t100644001751001751 140114052133701 16263 0ustar00colincolin000000000000Jenkins-API-0.18/tuse Test2::V0; use Test2::Tools::Explain; use Test2::Require::EnvVar 'LIVE_TEST_JENKINS_URL'; # Set LIVE_TEST_JENKINS_URL if you want to run these tests against a live jenkins server. # Set LIVE_TEST_JENKINS_API_KEY and LIVE_TEST_JENKINS_API_PASS if your server requires authentication. use Jenkins::API; my $url = $ENV{LIVE_TEST_JENKINS_URL}; my $apiKey = $ENV{LIVE_TEST_JENKINS_API_KEY}; my $apiPass = $ENV{LIVE_TEST_JENKINS_API_PASS}; my $api = Jenkins::API->new(base_url => $url, api_key => $apiKey, api_pass => $apiPass); my $v = $api->check_jenkins_url; ok $v, 'Jenkins running on ' . $url; note '$api->check_jenkins_url;'; note explain $v; my $status = $api->current_status; note '$api->current_status;'; note explain($status); done_testing; example000755001751001751 014052133701 14417 5ustar00colincolin000000000000Jenkins-API-0.18status.pl100755001751001751 137414052133701 16447 0ustar00colincolin000000000000Jenkins-API-0.18/example#!/usr/bin/env perl use strict; use warnings; use Jenkins::API; my $url = shift; unless ($url) { print "Usage $0 http://jenkins:8080/\n"; exit 1; } my $api = Jenkins::API->new({ base_url => $url }); unless($api->check_jenkins_url) { print "$url does not appear to be a valid jenkins url\n"; exit 2; } my $jobs = $api->current_status({ extra_params => { tree => 'jobs[name,color]' } }); my @job_list = @{$jobs->{jobs}}; @job_list = sort { $a->{name} cmp $b->{name} } @job_list; for my $job (@job_list) { # status isn't really this simple, but unstable doesn't # map very to the todos in perl, so I'm not interested # in it personally. my $status = $job->{color} eq 'blue' ? 'OK' : 'Fail'; print "$job->{name} - $status\n"; } Jenkins000755001751001751 014052133701 15133 5ustar00colincolin000000000000Jenkins-API-0.18/libAPI.pm100644001751001751 4500014052133701 16261 0ustar00colincolin000000000000Jenkins-API-0.18/lib/Jenkinspackage Jenkins::API; use Moo; use Types::Standard -types; use JSON; use MIME::Base64; use URI; use REST::Client; use HTTP::Status qw(HTTP_CREATED HTTP_FOUND HTTP_OK); # ABSTRACT: A wrapper around the Jenkins API our $VERSION = '0.18'; has base_url => (is => 'ro', isa => Str, required => 1); has api_key => (is => 'ro', isa => Maybe[Str], required => 0); has api_pass => (is => 'ro', isa => Maybe[Str], required => 0); has '_client' => ( is => 'ro', lazy => 1, default => sub { my $self = shift; my $client = REST::Client->new(); $client->setHost($self->base_url); if (defined($self->api_key) and defined($self->api_pass)) { $client->addHeader('Authorization', 'Basic ' . encode_base64($self->api_key . ':' . $self->api_pass)); } return $client; }, handles => { response_code => 'responseCode', response_content => 'responseContent', response_header => 'responseHeader' } ); sub create_job { my ($self, $name, $job_config) = @_; my $uri = URI->new($self->base_url); $uri->path_segments('createItem'); $uri->query_form( name => $name ); # curl -XPOST http://moe:8080/createItem?name=test -d@config.xml -v -H Content-Type:text/xml $self->_client->POST($uri->path_query, $job_config, { 'Content-Type' => 'text/xml' }); return $self->response_code == HTTP_OK; } sub delete_project { my ($self, $name) = @_; my $uri = URI->new($self->base_url); $uri->path_segments('job', $name, 'doDelete'); $self->_client->POST($uri->path_query, undef, { 'Content-Type' => 'text/xml' }); return $self->response_code == HTTP_FOUND; } sub trigger_build { my $self = shift; return $self->_trigger_build('build', @_); } sub trigger_build_with_parameters { my $self = shift; return $self->_trigger_build('buildWithParameters', @_); } sub _trigger_build { my $self = shift; my $build_url = shift; my $job = shift; my $extra_params = shift; my $uri = URI->new($self->base_url); $uri->path_segments('job', $job, $build_url); $uri->query_form($extra_params) if $extra_params; $self->_client->POST($uri->path_query); return $self->response_code == HTTP_CREATED; } sub project_config { my $self = shift; my $job = shift; my $extra_params = shift; my $uri = URI->new($self->base_url); $uri->path_segments('job', $job, 'config.xml'); $uri->query_form($extra_params) if $extra_params; $self->_client->GET($uri->path_query); return $self->response_content; } sub set_project_config { my $self = shift; my $job = shift; my $config = shift; my $uri = URI->new($self->base_url); $uri->path_segments('job', $job, 'config.xml'); $self->_client->POST($uri->path_query, $config, { 'Content-Type' => 'text/xml' }); return $self->response_code == HTTP_OK; } sub check_jenkins_url { my $self = shift; $self->_client->GET('/'); return $self->response_code == HTTP_OK && $self->response_header('X-Jenkins'); } sub build_queue { my $self = shift; return $self->_json_api(['queue', 'api','json'], @_); } sub load_statistics { my $self = shift; return $self->_json_api(['overallLoad', 'api','json'], @_); } sub get_job_details { my $self = shift; my $job_name = shift; return $self->_json_api(['job', $job_name, 'api', 'json'], @_); } sub current_status { my $self = shift; return $self->_json_api(['api','json'], @_); } sub view_status { my $self = shift; my $view = shift; return $self->_json_api(['view', $view, 'api', 'json'], @_); } sub _json_api { my $self = shift; my $uri_parts = shift; my $args = shift; my $extra_params = $args->{extra_params}; my $bits = $args->{path_parts} || []; my $uri = URI->new($self->base_url); $uri->path_segments(@$bits, @$uri_parts); $uri->query_form($extra_params) if $extra_params; $self->_client->GET($uri->path_query); die 'Invalid response' unless $self->response_code == HTTP_OK; # NOTE: my server returns UTF8, if this turns out to be a broken # assumption read the Content-Type header. my $data = JSON->new->utf8->decode($self->response_content()); return $data; } sub general_call { my $self = shift; my $uri_parts = shift; my $args = shift; my $extra_params = $args->{extra_params}; my $method = $args->{method} || 'GET'; my $decode_json = exists $args->{decode_json} ? $args->{decode_json} : 1; my $expected_response = $args->{expected_response_code} || HTTP_OK; my $uri = URI->new($self->base_url); $uri->path_segments(@$uri_parts); $uri->query_form($extra_params) if $extra_params; $self->_client->$method($uri->path_query); die 'Invalid response' unless $self->response_code == $expected_response; my $response = $self->response_content(); if($decode_json) { $response = JSON->new->utf8->decode($response); } return $response; } 1; # End of Jenkins::API __END__ =pod =encoding UTF-8 =head1 NAME Jenkins::API - A wrapper around the Jenkins API =head1 VERSION version 0.18 =head1 SYNOPSIS This is a wrapper around the Jenkins API. use Jenkins::API; my $jenkins = Jenkins::API->new({ base_url => 'http://jenkins:8080', api_key => 'username', api_pass => 'apitoken', }); my $status = $jenkins->current_status(); my @not_succeeded = grep { $_->{color} ne 'blue' } @{$status->{jobs}}; # { # 'color' => 'red', # 'name' => 'Test-Project', # 'url' => 'http://jenkins:8080/job/Test-Project/', # } my $success = $jenkins->create_job($project_name, $config_xml); ... =head2 ATTRIBUTES Specify these attributes to the constructor of the C object if necessary. =head2 base_url This is the base url for your Jenkins installation. This is commonly running on port 8080 so it's often something like http://jenkins:8080 =head2 api_key This is the username for the basic authentication if you have it turned on. If you don't, don't specify it. Note that Jenkins returns 403 error codes if authentication is required but hasn't been specified. A common setup is to allow build statuses to be read but triggering builds and making configuration changes to require authentication. Check L after making a call that fails to see if it is an authentication failure. my $success = $jenkins->trigger_build($job_name); unless($success) { if($jenkins->response_code == 403) { print "Auth failure\n"; } else { print $jenkins->response_content; } } =head2 api_pass The API token for basic auth. Go to the Jenkins wiki page on L for information on getting an API token for your user to use for authentication. =head1 METHODS =head2 check_jenkins_url Checks the url provided to the API has a Jenkins server running on it. It returns the version number of the Jenkins server if it is running. $jenkins->check_jenkins_url; # 1.460 =head2 current_status Returns the current status of the server as returned by the API. This is a hash containing a fairly comprehensive list of what's going on. $jenkins->current_status(); # { # 'assignedLabels' => [ # {} # ], # 'description' => undef, # 'jobs' => [ # { # 'color' => 'blue', # 'name' => 'Jenkins-API', # 'url' => 'http://jenkins:8080/job/Jenkins-API/' # }, # 'mode' => 'NORMAL', # 'nodeDescription' => 'the master Jenkins node', # 'nodeName' => '', # 'numExecutors' => 2, # 'overallLoad' => {}, # 'primaryView' => { # 'name' => 'All', # 'url' => 'http://jenkins:8080/' # }, # 'quietingDown' => bless( do{\(my $o = 0)}, 'JSON::XS::Boolean' ), # 'slaveAgentPort' => 0, # 'useCrumbs' => $VAR1->{'quietingDown'}, # 'useSecurity' => $VAR1->{'quietingDown'}, # 'views' => [ # { # 'name' => 'All', # 'url' => 'http://jenkins:8080/' # } # ] # } It is also possible to pass two parameters to the query to refine or expand the data you get back. The tree parameter allows you to select specific elements. The example from the Jenkins documentation , C<< tree=> 'jobs[name],views[name,jobs[name]]' >> demonstrates the syntax nicely. The other parameter you can pass is depth, by default it's 0, if you set it higher it dumps a ton of data. $jenkins->current_status({ extra_params => { tree => 'jobs[name,color]' }});; # { # 'jobs' => [ # { # 'color' => 'blue', # 'name' => 'Jenkins-API', # }, # ] # } $jenkins->current_status({ extra_params => { depth => 1 }}); # returns everything and the kitchen sink. It is also possible to only look at a subset of the data. Most urls you can see on the website in Jenkins can be accessed. If you have a job named Test-Project for example with the url C you can specify the C<< path_parts => ['job', 'Test-Project'] >> to look at the data for that job alone. $jenkins->current_status({ path_parts => [qw/job Test-Project/], extra_params => { depth => 1 }, }); # just returns the data relating to job Test-Project. # returning it in detail. The method will die saying 'Invalid response' if the server doesn't respond as it expects, or die with a JSON decoding error if the JSON parsing fails. =head2 get_job_details Returns detail about the job specified. $job_details = $jenkins->get_job_details('Test-Project'); # { # 'actions' => [], # 'buildable' => bless( do{\(my $o = 0)}, 'JSON::PP::Boolean' ), # 'builds' => [], # 'color' => 'disabled', # 'concurrentBuild' => $VAR1->{'buildable'}, # 'description' => '', # 'displayName' => 'Test-Project', # 'displayNameOrNull' => undef, # 'downstreamProjects' => [], # 'firstBuild' => undef, # 'healthReport' => [], # 'inQueue' => $VAR1->{'buildable'}, # 'keepDependencies' => $VAR1->{'buildable'}, # 'lastBuild' => undef, # 'lastCompletedBuild' => undef, # 'lastFailedBuild' => undef, # 'lastStableBuild' => undef, # 'lastSuccessfulBuild' => undef, # 'lastUnstableBuild' => undef, # 'lastUnsuccessfulBuild' => undef, # 'name' => 'Test-Project', # 'nextBuildNumber' => 1, # 'property' => [], # 'queueItem' => undef, # 'scm' => {}, # 'upstreamProjects' => [], # 'url' => 'http://jenkins-t2:8080/job/Test-Project/' # } The information can be refined in the same way as L using C. =head2 view_status Provides the status of the specified view. The list of views is provided in the general status report. $jenkins->view_status('MyView'); # { # 'busyExecutors' => {}, # 'queueLength' => {}, # 'totalExecutors' => {}, # 'totalQueueLength' => {} # } # { # 'description' => undef, # 'jobs' => [ # { # 'color' => 'blue', # 'name' => 'Test', # 'url' => 'http://jenkins-t2:8080/job/Test/' # } # ], # 'name' => 'Test', # 'property' => [], # 'url' => 'http://jenkins-t2:8080/view/Test/' # } This method allows the same sort of refinement as the L method. To just get the job info from the view for example you can do essentially the same, use Data::Dumper; my $view_list = $api->current_status({ extra_params => { tree => 'views[name]' }}); my @views = grep { $_ ne 'All' } map { $_->{name} } @{$view_list->{views}}; for my $view (@views) { my $view_jobs = $api->view_status($view, { extra_params => { tree => 'jobs[name,color]' }}); print Dumper($view_jobs); } # { # 'jobs' => [ # { # 'color' => 'blue', # 'name' => 'Test' # } # ] # } =head2 trigger_build Trigger a build, $success = $jenkins->trigger_build('Test-Project'); If you need to specify a token you can pass that like this, $jenkins->trigger_build('Test-Project', { token => $token }); Note that the success response is simply to indicate that the build has been scheduled, not that the build has succeeded. =head2 trigger_build_with_parameters Trigger a build with parameters, $success = $jenkins->trigger_build_with_parameters('Test-Project', { Parameter => 'Value' } ); The method behaves the same way as L. =head2 build_queue This returns the items in the build queue. $jenkins->build_queue(); This allows the same C as the L call. The depth and tree parameters work in the same way. See the Jenkins API documentation for more details. The method will die saying 'Invalid response' if the server doesn't respond as it expects, or die with a JSON decoding error if the JSON parsing fails. =head2 load_statistics This returns the load statistics for the server. $jenkins->load_statistics(); # { # 'busyExecutors' => {}, # 'queueLength' => {}, # 'totalExecutors' => {}, # 'totalQueueLength' => {} # } This also allows the same C as the L call. The depth and tree parameters work in the same way. See the Jenkins API documentation for more details. The method will die saying 'Invalid response' if the server doesn't respond as it expects, or die with a JSON decoding error if the JSON parsing fails. =head2 create_job Takes the project name and the XML for a config file and gets Jenkins to create the job. my $success = $api->create_job($project_name, $config_xml); =head2 project_config This method returns the configuration for the project in XML. my $config = $api->project_config($project_name); =head2 set_project_config This method allows you to set the configuration for the project using XML. my $success = $api->set_project_config($project_name, $config); =head2 delete_project Delete the project from Jenkins. my $success = $api->delete_project($project_name); =head2 general_call This is a catch all method for making a call to the API. Jenkins is extensible with plugins which can add new API end points. We can not predict all of these so this method allows you to call those functions without needing a specific method. general_call($url_parts, $args); my $response = $api->general_call( ['job', $job, 'api', 'json'], { method => 'GET', extra_params => { tree => 'color,description' }, decode_json => 1, expected_response_code => 200, }); # does a GET /job/$job/api/json?tree=color%2Cdescription # decodes the response as json # dies if a 200 response isn't returned. The arguments hash can contain these elements, =over =item * method Valid options are the HTTP verbs, make sure they are in caps. =item * extra_params Pass in extra parameters the method expects. =item * decode_json Defaulted to true. =item * expected_response_code Defaulted to 200 =back =head2 response_code This method returns the HTTP response code from our last request to the Jenkins server. This may be useful when an error occurred. =head2 response_content This method returns the content of the HTTP response from our last request to the Jenkins server. This may be useful when an error occurs. =head2 response_header This method returns the specified header of the HTTP response from our last request to the Jenkins server. The following example triggers a parameterized build, extracts the 'Location' HTTP response header, and selects certain elements of the queue item information $success = $jenkins->trigger_build_with_parameters('Test-Project', { Parameter => 'Value' } ); if ($success) { my $location = $jenkins->response_header('Location'); my $queue_item = $jenkins->general_call( [ URI->new($location)->path_segments, 'api', 'json' ], { extra_params => { tree => 'url,why,executable[url]' } } ); # { # 'executable' => { # 'url' => 'http://jenkins:8080/job/Test-Project/136/', # '_class' => 'org.jenkinsci.plugins.workflow.job.WorkflowRun' # }, # 'url' => 'queue/item/555125/', # 'why' => undef, # '_class' => 'hudson.model.Queue$LeftItem' # }; } else { print $jenkins->response_code; } =head1 BUGS The API wrapper doesn't deal with Jenkins installations not running from the root path. I don't actually know if that's an install option, but the internal url building just doesn't deal with that situation properly. If you want that fixing a patch is welcome. Please report any bugs or feature requests to through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Jenkins::API You can also look for information at: =over 4 =item * github issue list L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 SEE ALSO =over 4 =item * Jenkins CI server L =item * Net::Jenkins An alternative to this library. L =item * Task::Jenkins Libraries to help testing modules on a Jenkins server. L =back =head1 ACKNOWLEDGEMENTS Birmingham Perl Mongers for feedback before I released this to CPAN. With thanks to Nick Hu for adding the trigger_build_with_parameters method. Alex Kulbiy for the auth support and David Steinbrunner for some Makefile love. =head1 CONTRIBUTORS =over 4 =item * Nick Hu =item * David Steinbrunner =item * Alex Kulbiy =item * Piers Cawley =item * Arthur Axel 'fREW' Schmidt =item * Dave Horner L =item * Sven Willenbuecher =back =head1 AUTHOR Colin Newell =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012-2021 by Colin Newell. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut 00-report-prereqs.t100644001751001751 1342614052133701 17011 0ustar00colincolin000000000000Jenkins-API-0.18/t#!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.027 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec; # from $version::LAX my $lax_version_re = qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | (?:\.[0-9]+) (?:_[0-9]+)? ) | (?: v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? ) )/x; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _max { my $max = shift; $max = ( $_ > $max ) ? $_ : $max for @_; return $max; } sub _merge_prereqs { my ($collector, $prereqs) = @_; # CPAN::Meta::Prereqs object if (ref $collector eq $cpan_meta_pre) { return $collector->with_merged_prereqs( CPAN::Meta::Prereqs->new( $prereqs ) ); } # Raw hashrefs for my $phase ( keys %$prereqs ) { for my $type ( keys %{ $prereqs->{$phase} } ) { for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; } } } return $collector; } my @include = qw( ); my @exclude = qw( ); # Add static prereqs to the included modules list my $static_prereqs = do './t/00-report-prereqs.dd'; # Merge all prereqs (either with ::Prereqs or a hashref) my $full_prereqs = _merge_prereqs( ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), $static_prereqs ); # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; my $cpan_meta_error; if ( $source && $HAS_CPAN_META && (my $meta = eval { CPAN::Meta->load_file($source) } ) ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } else { $cpan_meta_error = $@; # capture error from CPAN::Meta->load_file($source) $source = 'static metadata'; } my @full_reports; my @dep_errors; my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; # Add static includes into a fake section for my $mod (@include) { $req_hash->{other}{modules}{$mod} = 0; } for my $phase ( qw(configure build test runtime develop other) ) { next unless $req_hash->{$phase}; next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); for my $type ( qw(requires recommends suggests conflicts modules) ) { next unless $req_hash->{$phase}{$type}; my $title = ucfirst($phase).' '.ucfirst($type); my @reports = [qw/Module Want Have/]; for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { next if $mod eq 'perl'; next if grep { $_ eq $mod } @exclude; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; if ($prefix) { my $have = MM->parse_version( File::Spec->catfile($prefix, $file) ); $have = "undef" unless defined $have; push @reports, [$mod, $want, $have]; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { if ( $have !~ /\A$lax_version_re\z/ ) { push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; } elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { push @dep_errors, "$mod version '$have' is not in required range '$want'"; } } } else { push @reports, [$mod, $want, "missing"]; if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { push @dep_errors, "$mod is not installed ($req_string)"; } } } if ( @reports ) { push @full_reports, "=== $title ===\n\n"; my $ml = _max( map { length $_->[0] } @reports ); my $wl = _max( map { length $_->[1] } @reports ); my $hl = _max( map { length $_->[2] } @reports ); if ($type eq 'modules') { splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; } else { splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; } push @full_reports, "\n"; } } } if ( @full_reports ) { diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( $cpan_meta_error || @dep_errors ) { diag "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n"; } if ( $cpan_meta_error ) { my ($orig_source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; diag "\nCPAN::Meta->load_file('$orig_source') failed with: $cpan_meta_error\n"; } if ( @dep_errors ) { diag join("\n", "\nThe following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass; # vim: ts=4 sts=4 sw=4 et: author000755001751001751 014052133701 14721 5ustar00colincolin000000000000Jenkins-API-0.18/xtpod-spell.t100644001751001751 60714052133701 17130 0ustar00colincolin000000000000Jenkins-API-0.18/xt/authoruse strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::PodSpelling 2.007004 use Test::Spelling 0.12; use Pod::Wordlist; add_stopwords(); all_pod_files_spelling_ok( qw( bin lib ) ); __DATA__ API Alex AnnoCPAN Arthur Axel Cawley Colin Dave David Horner Hu Jenkins Kulbiy Newell Nick Piers Schmidt Steinbrunner Sven Willenbuecher auth colin fREW https lib pod-syntax.t100644001751001751 25214052133701 17333 0ustar00colincolin000000000000Jenkins-API-0.18/xt/author#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); 00-report-prereqs.dd100644001751001751 421514052133701 17111 0ustar00colincolin000000000000Jenkins-API-0.18/tdo { my $x = { 'build' => { 'requires' => { 'Pod::Coverage::TrustPod' => '0', 'Test2::Suite' => '0.000082', 'Test2::Tools::Explain' => '0', 'Test::Pod::Coverage' => '0' } }, 'configure' => { 'requires' => { 'ExtUtils::MakeMaker' => '0' } }, 'develop' => { 'requires' => { 'File::Spec' => '0', 'IO::Handle' => '0', 'IPC::Open3' => '0', 'Pod::Coverage::TrustPod' => '0', 'Test::More' => '0.88', 'Test::Pod' => '1.41', 'Test::Pod::Coverage' => '1.08', 'Test::Spelling' => '0.12' } }, 'runtime' => { 'requires' => { 'File::ShareDir' => '0', 'JSON' => '0', 'MIME::Base64' => '0', 'Moo' => '0', 'REST::Client' => '0', 'Types::Standard' => '0', 'URI' => '0' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '2.120900' }, 'requires' => { 'ExtUtils::MakeMaker' => '0', 'File::Spec' => '0', 'Test::More' => '0' } } }; $x; }00-compile.t100644001751001751 254214052133701 17116 0ustar00colincolin000000000000Jenkins-API-0.18/xt/authoruse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.056 use Test::More; plan tests => 2; my @module_files = ( 'Jenkins/API.pm' ); # no fake home requested my @switches = ( -d 'blib' ? '-Mblib' : '-Ilib', ); use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } $^X, @switches, '-e', "require q[$lib]")) if $ENV{PERL_COMPILE_TEST_DEBUG}; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ); pod-coverage.t100644001751001751 171314052133701 17623 0ustar00colincolin000000000000Jenkins-API-0.18/xt/author#!perl # This file was automatically generated by Dist::Zilla::Plugin::Test::Pod::Coverage::Configurable. use Test::Pod::Coverage 1.08; use Test::More 0.88; BEGIN { if ( $] <= 5.008008 ) { plan skip_all => 'These tests require Pod::Coverage::TrustPod, which only works with Perl 5.8.9+'; } } use Pod::Coverage::TrustPod; my %skip = map { $_ => 1 } qw( ); my @modules; for my $module ( all_modules() ) { next if $skip{$module}; push @modules, $module; } plan skip_all => 'All the modules we found were excluded from POD coverage test.' unless @modules; plan tests => scalar @modules; my %trustme = (); my @also_private; for my $module ( sort @modules ) { pod_coverage_ok( $module, { coverage_class => 'Pod::Coverage::TrustPod', also_private => \@also_private, trustme => $trustme{$module} || [], }, "pod coverage for $module" ); } done_testing(); trigger_build_with_parameters.t100644001751001751 275214052133701 21662 0ustar00colincolin000000000000Jenkins-API-0.18/t#!/usr/bin/env perl # Set LIVE_TEST_JENKINS_URL if you want to run these tests against a live jenkins server. # Set LIVE_TEST_JENKINS_API_KEY and LIVE_TEST_JENKINS_API_PASS if your server requires authentication. use strict; use warnings; use Test2::V0 -target => 'Jenkins::API'; use HTTP::Status qw(HTTP_CREATED HTTP_UNAUTHORIZED); my $expected_base_url = 'http://jenkins:8080'; my $jenkins = $CLASS->new(base_url => $expected_base_url); my $mocked_response_code; my $mocked_client = Test2::Mock->new( class => 'REST::Client', override => [ POST => sub { cmp_ok $_[0]->getHost, 'eq', $expected_base_url, 'host configured'; cmp_ok $_[1], 'eq', '/job/Test-Project/buildWithParameters?Parameter=Value', 'query path'; return; }, responseCode => sub { return $mocked_response_code }, responseHeader => sub { my $location = URI->new($_[0]->getHost); $location->path_segments(qw(queue item 123456), ''); return $location->as_string; } ] ); $mocked_response_code = HTTP_UNAUTHORIZED; ok not($jenkins->trigger_build_with_parameters('Test-Project', { Parameter => 'Value' })), 'fail to trigger build with parameters'; $mocked_response_code = HTTP_CREATED; ok $jenkins->trigger_build_with_parameters('Test-Project', { Parameter => 'Value' }), 'build with parameters successfully triggered'; cmp_ok $jenkins->response_header('Location'), 'eq', "$expected_base_url/queue/item/123456/", 'validate location value'; done_testing;