Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Automattic/jenkins-php-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jenkins PHP API

Jenkins PHP API is a set of classes designed to interact with Jenkins CI using it's API.

Before anything, you need to instanciate the client :

    require_once('Autoload.php');
    Jenkins_Autoloader::register();
    $jenkins = new Jenkins('http://host.org:8080');

If your Jenkins need authentication, you need to pass and URL like this : 'http://user:token@host.org:8080'.

Here is some examples of how to use it :

Get the color of the job

    $job = $jenkins->getJob("dev2-pull");
    var_dump($job->getColor());
    //string(4) "blue"

Launch a Job

    $job = $jenkins->launchJob("clone-deploy");

List the jobs of a given view

    $view = $jenkins->getView('madb_deploy');
    foreach ($view->getJobs() as $job) {
      var_dump($job->getName());
    }
    //string(13) "altlinux-pull"
    //string(8) "dev-pull"
    //string(9) "dev2-pull"
    //string(11) "fedora-pull"

List builds and their status

    $job = $jenkins->getJob('dev2-pull');
    foreach ($job->getBuilds() as $build) {
      var_dump($build->getNumber());
      var_dump($build->getResult());
    }
    //int(122)
    //string(7) "SUCCESS"
    //int(121)
    //string(7) "FAILURE"

Check if Jenkins is available

    var_dump($jenkins->isAvailable());
    //bool(true);

More information about Jenkins API could be found here

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%