File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -345,6 +345,35 @@ export default async (ctx: Context): Promise<FastifyInstance<Server, IncomingMes
345345 }
346346 } ) ;
347347
348+ // Get build info
349+ server . get ( '/build/info' , opts , async ( request , reply ) => {
350+ let replyCode : number ;
351+ let replyBody : Record < string , any > ;
352+
353+ try {
354+ if ( ctx . build && ctx . build . id ) {
355+ const buildInfo = ctx . build ;
356+ const data = {
357+ buildId : buildInfo . id ,
358+ buildName : buildInfo . name ,
359+ baseline : buildInfo . baseline ,
360+ projectToken : ctx . env . PROJECT_TOKEN || '' ,
361+ }
362+ replyCode = 200 ;
363+ replyBody = { data : data } ;
364+ } else {
365+ throw new Error ( 'Build information is not available' ) ;
366+ }
367+ } catch ( error : any ) {
368+ ctx . log . debug ( `build info failed; ${ error } ` ) ;
369+ replyCode = 500 ;
370+ replyBody = { error : { message : error . message } } ;
371+ }
372+
373+ return reply . code ( replyCode ) . send ( replyBody ) ;
374+
375+ } ) ;
376+
348377 // Use the helper function to find and start server on available port
349378 if ( ctx . sourceCommand && ctx . sourceCommand === 'exec-start' ) {
350379
You can’t perform that action at this time.
0 commit comments