Skip to content
This repository has been archived by the owner on Feb 7, 2021. It is now read-only.

Commit

Permalink
Fixed #40: 0.3.0 release broke Jenkins job creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Pliakas committed Sep 30, 2014
1 parent d84ff72 commit 0d8f604
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/JenkinsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public function create()
$client->setSslVerification(false, false);
}

$configXml = file_get_contents(__DIR__ . '/../../../jenkins/config.xml');
$job = str_replace('{{ project.name }}', $this->projectName->get(), $configXml);
$job = str_replace('{{ project.name }}', $this->projectName->get(), $this->getConfigTemplate());

$headers = [
'Content-Type' => 'text/xml'
Expand All @@ -74,4 +73,12 @@ public function create()
$client->post($this->url . '/createItem', $headers, $job, $options)->send();
return true;
}

/**
* @return string
*/
public function getConfigTemplate()
{
return file_get_contents(__DIR__ . '/../jenkins/config.xml');
}
}
20 changes: 20 additions & 0 deletions test/JenkinsJobTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Cpliakas\PhpProjectStarter\Test;

use Cpliakas\PhpProjectStarter\JenkinsJob;
use Cpliakas\PhpProjectStarter\ProjectName;
use Cpliakas\PhpProjectStarter\Repository;
use GitWrapper\GitWrapper;

class JenkinsJobTest extends \PHPUnit_Framework_TestCase
{
public function testGetConfigTemplate()
{
$projectName = new ProjectName('cpliakas/test');
$repository = new Repository($projectName, new GitWrapper());
$jenkinsJob = new JenkinsJob($projectName, $repository, 'http://example.com');

$this->assertNotEmpty($jenkinsJob->getConfigTemplate());
}
}

0 comments on commit 0d8f604

Please sign in to comment.