From 71720471354e5c37b85149ffafb945f6ee8af483 Mon Sep 17 00:00:00 2001 From: Steven Cooney Date: Mon, 3 Jun 2019 17:14:07 +0100 Subject: [PATCH] Setup Shared Parameters for Builds Since there is limited access to parameters in the early stages of a build we need to pass through the shared parameters from the server to the agent. Once the BuildContext has these parameters we can then go forward and check all the required information is present before trying to patch in our revision changes. --- ...PhabricatorBuildStartContextProcessor.java | 22 +++++++++++++++++++ ...build-server-plugin-phabricator-plugin.xml | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Teamcity-Phabricator-Plugin/phabricator-plugin-server/src/main/java/uk/xlab/teamcity/phabricator/PhabricatorBuildStartContextProcessor.java diff --git a/Teamcity-Phabricator-Plugin/phabricator-plugin-server/src/main/java/uk/xlab/teamcity/phabricator/PhabricatorBuildStartContextProcessor.java b/Teamcity-Phabricator-Plugin/phabricator-plugin-server/src/main/java/uk/xlab/teamcity/phabricator/PhabricatorBuildStartContextProcessor.java new file mode 100644 index 0000000..f70731f --- /dev/null +++ b/Teamcity-Phabricator-Plugin/phabricator-plugin-server/src/main/java/uk/xlab/teamcity/phabricator/PhabricatorBuildStartContextProcessor.java @@ -0,0 +1,22 @@ +package uk.xlab.teamcity.phabricator; + +import java.util.Map; + +import jetbrains.buildServer.serverSide.BuildStartContext; +import jetbrains.buildServer.serverSide.BuildStartContextProcessor; + +public class PhabricatorBuildStartContextProcessor implements BuildStartContextProcessor { + + @Override + public void updateParameters(BuildStartContext context) { + // Get build parameters and put them in a shared location for access on the + // agent + Map parameters = context.getBuild().getBuildOwnParameters(); + + context.addSharedParameter(Constants.BRANCH_NAME, parameters.get(Constants.BRANCH_NAME)); + context.addSharedParameter(Constants.BUILD_ID, parameters.get(Constants.BUILD_ID)); + context.addSharedParameter(Constants.DIFF_ID, parameters.get(Constants.DIFF_ID)); + context.addSharedParameter(Constants.HARBORMASTER_PHID, parameters.get(Constants.HARBORMASTER_PHID)); + context.addSharedParameter(Constants.REVISION_ID, parameters.get(Constants.REVISION_ID)); + } +} diff --git a/Teamcity-Phabricator-Plugin/phabricator-plugin-server/src/main/resources/META-INF/build-server-plugin-phabricator-plugin.xml b/Teamcity-Phabricator-Plugin/phabricator-plugin-server/src/main/resources/META-INF/build-server-plugin-phabricator-plugin.xml index a6345e4..037ccd7 100644 --- a/Teamcity-Phabricator-Plugin/phabricator-plugin-server/src/main/resources/META-INF/build-server-plugin-phabricator-plugin.xml +++ b/Teamcity-Phabricator-Plugin/phabricator-plugin-server/src/main/resources/META-INF/build-server-plugin-phabricator-plugin.xml @@ -3,8 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" default-autowire="constructor"> - + +