Example #1
0
 public function testFactoryCreatesJobWithDefaults()
 {
     $job = Job::factory($this->jenkins, new JsonData(array('name' => "testJob", 'url' => "/job/testJob")));
     $this->assertEquals(array(), $job->actions);
     $this->assertTrue($job->buildable);
     $this->assertEquals(array(), $job->builds);
     $this->assertEquals("gray", $job->color);
     $this->assertFalse($job->concurrentBuild);
     $this->assertEquals("", $job->description);
     $this->assertEquals("", $job->displayName);
     $this->assertNull($job->displayNameOrNull);
     $this->assertEquals(array(), $job->downstreamProjects);
     $this->assertEquals(array(), $job->healthReport);
     $this->assertFalse($job->inQueue);
     $this->assertFalse($job->keepDependencies);
     $this->assertEquals("testJob", $job->name);
     $this->assertEquals(0, $job->nextBuildNumber);
     $this->assertEquals(array(), $job->property);
     $this->assertNull($job->queueItem);
     $this->assertEquals(array(), $job->scm);
     $this->assertEquals(array(), $job->upstreamProjects);
     $this->assertEquals("/job/testJob", $job->url);
     $this->assertNull($job->firstBuild);
     $this->assertNull($job->lastBuild);
     $this->assertNull($job->lastCompletedBuild);
     $this->assertNull($job->lastFailedBuild);
     $this->assertNull($job->lastStableBuild);
     $this->assertNull($job->lastSuccessfulBuild);
     $this->assertNull($job->lastUnstableBuild);
     $this->assertNull($job->lastUnsuccessfulBuild);
 }
Example #2
0
 /**
  * Constructs an array of jobs from data, which is assumed to be an array of data that
  * would have come from a Jenkins API call
  *
  * @param Jenkins $conn
  * @param array $data
  * @return array[\mogman1\Jenkins\Job]
  */
 public static function multiFactory(Jenkins $conn, array $data)
 {
     $jobs = array();
     foreach ($data as $jobData) {
         $jobs[] = Job::factory($conn, new JsonData($jobData));
     }
     return $jobs;
 }
Example #3
0
 public function getJob($name)
 {
     return Job::factory($this, $this->get(Job::getUrlFromName($name))->getJson());
 }
Example #4
0
 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;
 }