Exemplo n.º 1
0
 /**
  * @param Commit $commit
  * @throws GitHookException
  * @throws GitException
  */
 public function run(Commit $commit)
 {
     if ($this->job->isHealthy()) {
         $this->logger->debug('Jenkins job is healthy.');
         return;
     }
     $this->logger->info('Jenkins job is not healthy...asserting that commit message contains {buildfix} hash');
     $messageSubject = $commit->messageSubject();
     $buildFixDirective = Directives::BUILD_FIX();
     // Check if commit has buildfix directive
     if (preg_match("/{$buildFixDirective->value()}/", $messageSubject) > 0) {
         $this->logger->info("Commit has {$buildFixDirective} directive. It attempts to fix build");
         return;
     }
     throw new GitHookException('Jenkins not healthy and commit does not fix it');
 }
Exemplo n.º 2
0
 public function test_is_unhealthy()
 {
     $this->configure_for_health_tests(123, 122);
     $job = new Job(self::$domain, self::$job_name);
     $this->assertFalse($job->is_healthy(), 'Expected that job would be unhealthy');
 }
Exemplo n.º 3
0
 public function testIsUnhealthy()
 {
     $conn = $this->configureForHealthTests(123, 122);
     $job = new Job($conn, self::$projectPath);
     $this->assertFalse($job->is_healthy(), 'Expected that job would be unhealthy');
 }