@@ -271,15 +271,42 @@ function configureBuildTools(
271271 project : z . string ( ) . describe ( "Project ID or name to run the build in" ) ,
272272 definitionId : z . number ( ) . describe ( "ID of the build definition to run" ) ,
273273 sourceBranch : z . string ( ) . optional ( ) . describe ( "Source branch to run the build from. If not provided, the default branch will be used." ) ,
274+ parameters : z . record ( z . string ( ) , z . string ( ) ) . optional ( ) . describe ( "Custom build parameters as key-value pairs" ) ,
274275 } ,
275- async ( { project, definitionId, sourceBranch } ) => {
276+ async ( { project, definitionId, sourceBranch, parameters } ) => {
276277 const connection = await connectionProvider ( ) ;
277278 const buildApi = await connection . getBuildApi ( ) ;
278- const build = await buildApi . queueBuild ( { definition : { id : definitionId } , sourceBranch } , project ) ;
279+ const pipelinesApi = await connection . getPipelinesApi ( ) ;
280+ const definition = await buildApi . getDefinition ( project , definitionId ) ;
281+ const runRequest = {
282+ resources : {
283+ repositories : {
284+ self : {
285+ refName :
286+ sourceBranch ||
287+ definition . repository ?. defaultBranch ||
288+ "refs/heads/main" ,
289+ } ,
290+ } ,
291+ } ,
292+ templateParameters : parameters ,
293+ } ;
294+
295+ const pipelineRun = await pipelinesApi . runPipeline (
296+ runRequest ,
297+ project ,
298+ definitionId
299+ ) ;
300+ const queuedBuild = { id : pipelineRun . id } ;
301+ const buildId = queuedBuild . id ;
302+ if ( buildId === undefined ) {
303+ throw new Error ( "Failed to get build ID from pipeline run" ) ;
304+ }
279305
306+ const buildReport = await buildApi . getBuildReport ( project , buildId ) ;
280307 return {
281- content : [ { type : "text" , text : JSON . stringify ( build , null , 2 ) } ] ,
282- } ;
308+ content : [ { type : "text" , text : JSON . stringify ( buildReport , null , 2 ) } ] ,
309+ } ;
283310 }
284311 ) ;
285312
0 commit comments