public function testMockedBuild()
 {
     $this->mockServer->queueResponse($this->getTestData(__FUNCTION__));
     $build = new Build($this->jenkins, "jenkins-web-api", "123");
     $build->update();
     $actions = array(array('causes' => array(array('shortDescription' => "Started by an SCM change"))), array("failCount" => 0, "skipCount" => 0, "totalCount" => 214, "urlName" => "testReport"));
     $this->assertEquals($actions, $build->actions);
     $this->assertEquals(array(), $build->artifacts);
     $this->assertTrue($build->building);
     $this->assertEquals("urmom", $build->builtOn);
     $this->assertEquals(1, count($build->changeSet['items']));
     $this->assertTrue(isset($build->changeSet['items'][0]['timestamp']));
     $this->assertEquals(2, count($build->culprits));
     $this->assertEquals("shaun.carlson", $build->culprits[0]['fullName']);
     $this->assertEquals("Shaun Carlson", $build->culprits[1]['fullName']);
     $this->assertEquals("message!", $build->description);
     $this->assertEquals(1095396, $build->duration);
     $this->assertEquals(555548, $build->estimatedDuration);
     $this->assertEquals("", $build->executor);
     $this->assertEquals("jenkins-web-api #123", $build->fullDisplayName);
     $this->assertEquals("2013-09-08_00-23-08", $build->id);
     $this->assertTrue($build->keepLog);
     $this->assertEquals("UNSTABLE", $build->result);
     $this->assertEquals(1378599788000, $build->timestamp);
 }
Exemple #2
0
 /**
  * (non-PHPdoc)
  * @see \mogman1\Jenkins\ApiObject::updateImpProperties()
  */
 protected function updateImpProperties(JsonData $data)
 {
     //url and name are not updated since, once they are set, they should never change
     //TODO: figure out what actions are
     $this->actions = $data->get('actions', array());
     $this->buildable = $data->get('buildable', TRUE);
     $this->builds = Build::multiFactory($this->conn, $this->name, $data->get('builds', array()));
     $this->color = $data->get('color', "gray");
     $this->concurrentBuild = $data->get('concurrentBuild', FALSE);
     $this->description = $data->get('description', "");
     $this->displayName = $data->get('displayName', "");
     $this->displayNameOrNull = $data->get('displayNameOrNull', NULL);
     $this->downstreamProjects = $data->get('downstreamProjects', array());
     //TODO: create health report object
     $this->healthReport = $data->get('healthReport', array());
     $this->inQueue = $data->get('inQueue', FALSE);
     $this->keepDependencies = $data->get('keepDependencies', FALSE);
     $this->nextBuildNumber = $data->get('nextBuildNumber', "0");
     $this->property = $data->get('property', array());
     $this->queueItem = $data->get('queueItem', NULL);
     $this->scm = $data->get('scm', array());
     $this->upstreamProjects = $data->get('upstreamProjects', array());
     $build = $data->get('firstBuild', array());
     $this->firstBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL;
     $build = $data->get('lastBuild', array());
     $this->lastBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL;
     $build = $data->get('lastCompletedBuild', array());
     $this->lastCompletedBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL;
     $build = $data->get('lastFailedBuild', array());
     $this->lastFailedBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL;
     $build = $data->get('lastStableBuild', array());
     $this->lastStableBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL;
     $build = $data->get('lastSuccessfulBuild', array());
     $this->lastSuccessfulBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL;
     $build = $data->get('lastUnstableBuild', array());
     $this->lastUnstableBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL;
     $build = $data->get('lastUnsuccessfulBuild', array());
     $this->lastUnsuccessfulBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL;
 }
Exemple #3
0
 public static function multiFactory(Jenkins $conn, $jobName, array $data)
 {
     $builds = array();
     foreach ($data as $buildData) {
         $builds[] = Build::factory($conn, $jobName, new JsonData($buildData));
     }
     return $builds;
 }
 protected function updateImpProperties(JsonData $data)
 {
     //id and url are not updated since, once they are set, they should never change
     //TODO: figure out what actions are
     $this->actions = $data->get('actions', array());
     $this->blocked = $data->get('blocked', FALSE);
     $this->buildable = $data->get('buildable', FALSE);
     $this->cancelled = $data->get('cancelled', FALSE);
     $this->inQueueSince = $data->get('inQueueSince', "0");
     $this->params = $this->parseParamsString($data->get('params', ""));
     $this->stuck = $data->get('stuck', FALSE);
     $this->timestamp = $data->get('timestamp', "0");
     $this->why = $data->get('why', "");
     $task = $data->get('task', array());
     $this->task = $task ? Job::factory($this->conn, new JsonData($data->get('task', array()))) : NULL;
     $build = $data->get('executable', array());
     $this->executable = $build ? Build::factory($this->conn, $this->task->name, new JsonData($build)) : NULL;
 }