1
0
Fork 0

Remove BRANCH_NAME Parameter

In the past TeamCity allowed us to spoof the branch we ran a build configuration on. We were going to utilise this with each differential revision having its own TeamCity branch. However in a recent change (post 2018.2.2) branches specified in builds must have a corresponding VCS branch otherwise the build is marked as failed. We therefore don't need a branch name within the teamcity plugin.

We are still passing through the REVISION_BUILD to allow us to display the snapshot within TeamCity.
This commit is contained in:
Steven Cooney 2019-06-05 11:22:53 +01:00
parent 8d56fa3128
commit cefb59b73a
5 changed files with 4 additions and 17 deletions

View file

@ -59,7 +59,7 @@ final class HarbormasterTeamCityBuildStepImplementation
$xmlBuilder = new TeamCityXmlBuildBuilder(); $xmlBuilder = new TeamCityXmlBuildBuilder();
$payload = $xmlBuilder $payload = $xmlBuilder
->addBuildId($settings['buildId']) ->addBuildId($settings['buildId'])
->addBranchName(implode(array("D", $variables['buildable.revision'], "-", $variables['build.id']))) ->addRevisionBuild(implode(array("D", $variables['buildable.revision'], "-", $variables['buildable.diff'])))
->addPhabBuildId($variables['build.id']) ->addPhabBuildId($variables['build.id'])
->addDiffId($variables['buildable.diff']) ->addDiffId($variables['buildable.diff'])
->addHarbormasterPHID($variables['target.phid']) ->addHarbormasterPHID($variables['target.phid'])

View file

@ -33,11 +33,8 @@ final class TeamCityXmlBuildBuilder {
return $this; return $this;
} }
function addBranchName($branchName){ function addRevisionBuild($revisionBuild){
// $this-> $this->addProperty("phabricator.REVISION_BUILD", $revisionBuild);
// root->
// setAttribute('branchName', $branchName);
$this->addProperty("phabricator.BRANCH_NAME", $branchName);
return $this; return $this;
} }

View file

@ -11,7 +11,6 @@ public class Constants {
public static final String PHABRICATOR_CONDUIT_TOKEN_SETTING = "plugin.conduitToken"; public static final String PHABRICATOR_CONDUIT_TOKEN_SETTING = "plugin.conduitToken";
// Build Config // Build Config
public static final String BRANCH_NAME = "phabricator.BRANCH_NAME";
public static final String BUILD_ID = "phabricator.BUILD_ID"; public static final String BUILD_ID = "phabricator.BUILD_ID";
public static final String DIFF_ID = "phabricator.DIFF_ID"; public static final String DIFF_ID = "phabricator.DIFF_ID";
public static final String HARBORMASTER_PHID = "phabricator.HARBORMASTER_TARGET_PHID"; public static final String HARBORMASTER_PHID = "phabricator.HARBORMASTER_TARGET_PHID";

View file

@ -23,7 +23,6 @@ public class PhabricatorPluginConfig {
private String conduitToken; private String conduitToken;
// Harbormaster Variables // Harbormaster Variables
private String branchName;
private String buildId; private String buildId;
private String diffId; private String diffId;
private String harbormasterPHID; private String harbormasterPHID;
@ -67,10 +66,6 @@ public class PhabricatorPluginConfig {
logger.info("Found Phabricator Conduit Token"); logger.info("Found Phabricator Conduit Token");
conduitToken = params.get(Constants.PHABRICATOR_CONDUIT_TOKEN_SETTING); conduitToken = params.get(Constants.PHABRICATOR_CONDUIT_TOKEN_SETTING);
break; break;
case Constants.BRANCH_NAME:
logger.info(String.format("Found branch name: %s", params.get(Constants.BRANCH_NAME)));
branchName = params.get(Constants.BRANCH_NAME);
break;
case Constants.BUILD_ID: case Constants.BUILD_ID:
logger.info(String.format("Found build id: %s", params.get(Constants.BUILD_ID))); logger.info(String.format("Found build id: %s", params.get(Constants.BUILD_ID)));
buildId = params.get(Constants.BUILD_ID); buildId = params.get(Constants.BUILD_ID);
@ -97,7 +92,7 @@ public class PhabricatorPluginConfig {
} }
public boolean isPluginSetup() { public boolean isPluginSetup() {
if (!isNull(phabricatorUrl) && !isNullOrEmpty(branchName) && !isNullOrEmpty(buildId) && !isNullOrEmpty(diffId) if (!isNull(phabricatorUrl) && !isNullOrEmpty(buildId) && !isNullOrEmpty(diffId)
&& !isNullOrEmpty(harbormasterPHID) && !isNullOrEmpty(revisionId)) { && !isNullOrEmpty(harbormasterPHID) && !isNullOrEmpty(revisionId)) {
return true; return true;
} }

View file

@ -13,10 +13,6 @@ public class PhabricatorBuildStartContextProcessor implements BuildStartContextP
// agent // agent
Map<String, String> parameters = context.getBuild().getBuildOwnParameters(); Map<String, String> parameters = context.getBuild().getBuildOwnParameters();
if (parameters.containsKey(Constants.BRANCH_NAME)) {
context.addSharedParameter(Constants.BRANCH_NAME, parameters.get(Constants.BRANCH_NAME));
}
if (parameters.containsKey(Constants.BUILD_ID)) { if (parameters.containsKey(Constants.BUILD_ID)) {
context.addSharedParameter(Constants.BUILD_ID, parameters.get(Constants.BUILD_ID)); context.addSharedParameter(Constants.BUILD_ID, parameters.get(Constants.BUILD_ID));
} }