Download the PHP package mogman1/jenkins-web-api without Composer

On this page you can find all versions of the php package mogman1/jenkins-web-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package jenkins-web-api

Jenkins Web API

Build Status

I only noticed, somewhat sheepishly, that there were two other Jenkins PHP libraries already out there by the time I finished my work on this. Admittedly, at present this library doesn't break any new ground, it provides an API for reading the most common data from Jenkins in addition to being able to trigger remote builds. Future releases already in the works will allow creating new objects on Jenkins (like jobs), as well as reading them.

Currently, the following data objects are supported:

Installation

This package can be installed using composer:

Usage

All implementations of ApiObject use the Jenkins class to communicate with your Jenkins server, with the actual connection information managed by the Http class:

The library assumes that Jenkins' CSRF crumb tokens are being used and automatically fetches a crumb for each request (a future release will check if crumbs are being used and change behaviour accordingly).

The Jenkins class can be used to fetch top-level information, such as info on the Views available, the Jenkins Node, or available Jobs.

When objects are returned as part of information obtained from other objects, like the jobs returned from the Node object, they are usually in reduced-info state to minimize calls to Jenkins for information until you really need it. The get all fields available for that object, or simply to fetch the latest from the server, use the update() method:

You can also directly fetch a job you already know the name of, which will come back with all information already loaded (no need to call update()).

Job objects are also capable of triggering builds. If you have parameters enabled for your job, you can pass them in as an array. If your job requires the additional authentication token, you'll need to pass this in as one of the parameters. The return value here is a QueueItem because Jenkins doesn't create an actual build right away (see this comment from the Jenkins issue tracker).

Getting information on the build you triggered can require some shenanigans. Generally a queue item is stuck in a Jenkins queue for a several seconds before being acted on by Jenkins, so you'll have to poll this object until the build becomes available under QueueItem::$executable. However, please note that eventually queued items get removed from the Jenkins queue and you won't be able to fetch data on it anymore (you'll get a 404 response which triggers an exception). My experience is that it you have plenty of time before it goes away, but keep that in mind.

Finally, you can run a query directly against the Jenkins server with the get() method on the Jenkins class. The first parameter is the path to query on the server, and the second is an associative array of any parameters you might wish to submit with your request. The return type is HttpResponse:

For everything else, take a look at the code. All methods and properties have been commented to explain what they do (to the best of my knowledge at the time). Please feel free to get in contact with me for feature requests, bug fixes, or anything else.

Looking Forward

There are a few areas that I know will have interface-breaking changes sooner than later:

Basically any place where an array is being returned, I'm hoping to be able to convert into full-on objects once I understand the what's being returned from Jenkins better.


All versions of jenkins-web-api with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mogman1/jenkins-web-api contains the following files

Loading the files please wait ....