2019-05-30 14:16:13 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class TeamCityXmlBuildBuilder {
|
|
|
|
|
|
|
|
private $xml;
|
|
|
|
private $root;
|
|
|
|
|
|
|
|
function __construct(){
|
|
|
|
$this->xml = new DOMDocument('1.0', 'UTF-8');
|
|
|
|
$this->root = $this->xml->createElement('build');
|
|
|
|
}
|
|
|
|
|
|
|
|
function addBuildId($buildId){
|
|
|
|
$buildIdElement =
|
|
|
|
$this->
|
|
|
|
xml->
|
|
|
|
createElement('buildType');
|
|
|
|
|
|
|
|
$buildIdElement->setAttribute('id', $buildId);
|
|
|
|
|
|
|
|
$this->root->appendChild($buildIdElement);
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
function addPhabBuildId($buildId){
|
2019-06-03 17:57:50 +02:00
|
|
|
$this->addProperty("phabricator.BUILD_ID", $buildId);
|
2019-05-30 14:16:13 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
function addRevisionId($revisionId){
|
2019-06-03 17:57:50 +02:00
|
|
|
$this->addProperty("phabricator.REVISION_ID", $revisionId);
|
2019-05-30 14:16:13 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2019-06-05 12:22:53 +02:00
|
|
|
function addRevisionBuild($revisionBuild){
|
|
|
|
$this->addProperty("phabricator.REVISION_BUILD", $revisionBuild);
|
2019-05-30 14:16:13 +02:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
function addHarbormasterPHID($phid){
|
2019-06-03 17:57:50 +02:00
|
|
|
$this->addProperty('phabricator.HARBORMASTER_TARGET_PHID', $phid);
|
2019-05-30 14:16:13 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
function addDiffId($diffId){
|
2019-06-03 17:57:50 +02:00
|
|
|
$this->addProperty('phabricator.DIFF_ID', $diffId);
|
2019-05-30 14:16:13 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
function build(){
|
|
|
|
$this->xml->appendChild($this->root);
|
|
|
|
return $this->xml->saveXML();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function addProperty($name, $value){
|
|
|
|
$this->verifyPropertiesExist();
|
|
|
|
|
|
|
|
$property = $this->xml->createElement('property');
|
|
|
|
$property->setAttribute('name', $name);
|
|
|
|
$property->setAttribute('value', $value);
|
|
|
|
|
|
|
|
$this->
|
|
|
|
root->
|
|
|
|
getElementsByTagName('properties')->
|
|
|
|
item(0)->
|
|
|
|
appendChild($property);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function verifyPropertiesExist(){
|
|
|
|
if($this->root->getElementsByTagName('properties')->length == 0){
|
|
|
|
$propertiesElement = $this->xml->createElement('properties');
|
|
|
|
$this->root->appendChild($propertiesElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|