@daghis/teamcity-mcp 1.10.2 → 1.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "1.10.2"
2
+ ".": "1.10.3"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.10.3](https://github.com/Daghis/teamcity-mcp/compare/teamcity-mcp-v1.10.2...teamcity-mcp-v1.10.3) (2025-09-27)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **tools:** honor trigger_build branch overrides (210) ([#223](https://github.com/Daghis/teamcity-mcp/issues/223)) ([7222c28](https://github.com/Daghis/teamcity-mcp/commit/7222c28c4fc9a307222ee9a50fa518127f5187de))
9
+
3
10
  ## [1.10.2](https://github.com/Daghis/teamcity-mcp/compare/teamcity-mcp-v1.10.1...teamcity-mcp-v1.10.2) (2025-09-27)
4
11
 
5
12
 
package/dist/index.js CHANGED
@@ -38549,7 +38549,12 @@ var DEV_TOOLS = [
38549
38549
  properties: {
38550
38550
  buildTypeId: { type: "string", description: "Build type ID to trigger" },
38551
38551
  branchName: { type: "string", description: "Branch to build (optional)" },
38552
- comment: { type: "string", description: "Build comment (optional)" }
38552
+ comment: { type: "string", description: "Build comment (optional)" },
38553
+ properties: {
38554
+ type: "object",
38555
+ description: "Optional build parameters to set when triggering the build",
38556
+ additionalProperties: { type: "string" }
38557
+ }
38553
38558
  },
38554
38559
  required: ["buildTypeId"]
38555
38560
  },
@@ -38557,35 +38562,84 @@ var DEV_TOOLS = [
38557
38562
  const schema = import_zod4.z.object({
38558
38563
  buildTypeId: import_zod4.z.string().min(1),
38559
38564
  branchName: import_zod4.z.string().min(1).max(255).optional(),
38560
- comment: import_zod4.z.string().max(500).optional()
38565
+ comment: import_zod4.z.string().max(500).optional(),
38566
+ properties: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.string()).optional()
38561
38567
  });
38562
38568
  return runTool(
38563
38569
  "trigger_build",
38564
38570
  schema,
38565
38571
  async (typed) => {
38566
38572
  const adapter = createAdapterFromTeamCityAPI(TeamCityAPI.getInstance());
38567
- try {
38568
- const build = await adapter.triggerBuild(
38569
- typed.buildTypeId,
38570
- typed.branchName,
38571
- typed.comment
38573
+ const directBranch = typed.branchName?.trim();
38574
+ const normalizedDirectBranch = directBranch && directBranch.length > 0 ? directBranch : void 0;
38575
+ const rawPropertyBranch = typed.properties?.["teamcity.build.branch"];
38576
+ const trimmedPropertyBranch = rawPropertyBranch?.trim();
38577
+ const normalizedPropertyBranch = trimmedPropertyBranch && trimmedPropertyBranch.length > 0 ? trimmedPropertyBranch : void 0;
38578
+ const branchName = normalizedDirectBranch ?? normalizedPropertyBranch;
38579
+ if (normalizedDirectBranch && normalizedPropertyBranch && normalizedDirectBranch !== normalizedPropertyBranch) {
38580
+ const errorPayload = {
38581
+ success: false,
38582
+ action: "trigger_build",
38583
+ error: `Conflicting branch overrides: branchName='${normalizedDirectBranch}' vs properties.teamcity.build.branch='${normalizedPropertyBranch}'.`
38584
+ };
38585
+ return {
38586
+ success: false,
38587
+ error: errorPayload.error,
38588
+ content: [{ type: "text", text: JSON.stringify(errorPayload, null, 2) }]
38589
+ };
38590
+ }
38591
+ const propertyEntries = typed.properties ? Object.entries(typed.properties).map(([name, value]) => ({
38592
+ name,
38593
+ value: name === "teamcity.build.branch" && normalizedPropertyBranch ? normalizedPropertyBranch : value
38594
+ })) : [];
38595
+ const propertiesPayload = propertyEntries.length > 0 ? { property: propertyEntries } : void 0;
38596
+ const buildRequest = {
38597
+ buildType: { id: typed.buildTypeId }
38598
+ };
38599
+ if (branchName) {
38600
+ buildRequest.branchName = branchName;
38601
+ }
38602
+ const commentText = typed.comment?.trim();
38603
+ if (commentText && commentText.length > 0) {
38604
+ buildRequest.comment = { text: commentText };
38605
+ }
38606
+ if (propertiesPayload) {
38607
+ buildRequest.properties = propertiesPayload;
38608
+ }
38609
+ const sendXmlFallback = async (error2) => {
38610
+ const escapeXml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
38611
+ const branchPart = branchName ? `<branchName>${escapeXml(branchName)}</branchName>` : "";
38612
+ const commentPart = commentText ? `<comment><text>${escapeXml(commentText)}</text></comment>` : "";
38613
+ const propertiesPart = propertiesPayload ? `<properties>${propertiesPayload.property.map(
38614
+ (prop) => `<property name="${escapeXml(prop.name)}" value="${escapeXml(prop.value)}"/>`
38615
+ ).join("")}</properties>` : "";
38616
+ const xml = `<?xml version="1.0" encoding="UTF-8"?><build><buildType id="${escapeXml(
38617
+ typed.buildTypeId
38618
+ )}"/>${branchPart}${commentPart}${propertiesPart}</build>`;
38619
+ const response = await adapter.modules.buildQueue.addBuildToQueue(
38620
+ false,
38621
+ xml,
38622
+ {
38623
+ headers: { "Content-Type": "application/xml", Accept: "application/json" }
38624
+ }
38572
38625
  );
38626
+ const build = response.data;
38573
38627
  return json({
38574
38628
  success: true,
38575
38629
  action: "trigger_build",
38576
38630
  buildId: String(build.id ?? ""),
38577
38631
  state: build.state ?? void 0,
38578
- status: build.status ?? void 0
38632
+ status: build.status ?? void 0,
38633
+ branchName: build.branchName ?? branchName,
38634
+ fallback: { mode: "xml", reason: error2?.message }
38579
38635
  });
38580
- } catch (e) {
38581
- const branchPart = typed.branchName ? `<branchName>${typed.branchName}</branchName>` : "";
38582
- const commentPart = typed.comment ? `<comment><text>${typed.comment.replace(/</g, "&lt;").replace(/>/g, "&gt;")}</text></comment>` : "";
38583
- const xml = `<?xml version="1.0" encoding="UTF-8"?><build><buildType id="${typed.buildTypeId}"/>${branchPart}${commentPart}</build>`;
38636
+ };
38637
+ try {
38584
38638
  const response = await adapter.modules.buildQueue.addBuildToQueue(
38585
38639
  false,
38586
- xml,
38640
+ buildRequest,
38587
38641
  {
38588
- headers: { "Content-Type": "application/xml", Accept: "application/json" }
38642
+ headers: { "Content-Type": "application/json", Accept: "application/json" }
38589
38643
  }
38590
38644
  );
38591
38645
  const build = response.data;
@@ -38594,8 +38648,11 @@ var DEV_TOOLS = [
38594
38648
  action: "trigger_build",
38595
38649
  buildId: String(build.id ?? ""),
38596
38650
  state: build.state ?? void 0,
38597
- status: build.status ?? void 0
38651
+ status: build.status ?? void 0,
38652
+ branchName: build.branchName ?? branchName
38598
38653
  });
38654
+ } catch (error2) {
38655
+ return sendXmlFallback(error2);
38599
38656
  }
38600
38657
  },
38601
38658
  args