@@ -8,6 +8,7 @@ import { getBuildConfigs } from './helpers';
88interface BuildResult { result : string ; message : string }
99
1010const DISABLED = 'disabled' ;
11+ const INVALID = 'invalid' ;
1112
1213const buildResultCode = {
1314 0 : 'None' ,
@@ -27,13 +28,16 @@ const buildResultEnum = {
2728
2829async function main ( ) {
2930 const disabledPipelines : string [ ] = [ ] ;
31+ const invalidPipelines : string [ ] = [ ] ;
3032 const runningTestBuilds : Promise < BuildResult > [ ] = [ ] ;
3133 for ( const task of api . tasks ) {
3234 console . log ( `starting tests for ${ task } task` ) ;
3335 const runResult = await runTaskPipelines ( task ) ;
3436
3537 if ( runResult === DISABLED ) {
3638 disabledPipelines . push ( task ) ;
39+ } else if ( runResult === INVALID ) {
40+ invalidPipelines . push ( task ) ;
3741 } else {
3842 runningTestBuilds . push ( ...runResult ) ;
3943 }
@@ -65,13 +69,23 @@ async function main() {
6569 ) ) ;
6670 }
6771
72+ if ( invalidPipelines . length > 0 ) {
73+ console . log ( '\nInvalid pipelines (can not be triggered due to an incorrect YML file structure and/or issues with pipeline resources such as service connections):' ) ;
74+
75+ invalidPipelines . map ( invalidPipeline => console . log (
76+ `##vso[task.issue type=error]${ invalidPipeline } is not valid`
77+ ) ) ;
78+
79+ failed = true ;
80+ }
81+
6882 console . log ( '\n' ) ;
6983 if ( failed ) console . log ( '##vso[task.complete result=Failed]' ) ;
7084 } ) ;
7185}
7286
7387// Running test pipelines for task by build configs
74- async function runTaskPipelines ( taskName : string ) : Promise < Promise < BuildResult > [ ] | typeof DISABLED > {
88+ async function runTaskPipelines ( taskName : string ) : Promise < Promise < BuildResult > [ ] | typeof DISABLED | typeof INVALID > {
7589 const pipelines = await fetchPipelines ( ) ( ) ;
7690 const pipeline = pipelines . find ( pipeline => pipeline . name === taskName ) ;
7791
@@ -89,6 +103,11 @@ async function runTaskPipelines(taskName: string): Promise<Promise<BuildResult>[
89103 console . log ( `Running tests for "${ taskName } " task with config "${ config } " for pipeline "${ pipeline . name } "` ) ;
90104 const pipelineBuild = await startTestPipeline ( pipeline , config ) ;
91105
106+ if ( pipelineBuild === null ) {
107+ console . log ( `Pipeline "${ pipeline . name } " is not valid.` ) ;
108+ return INVALID ;
109+ }
110+
92111 const buildPromise = new Promise < BuildResult > ( resolve => completeBuild ( taskName , pipelineBuild , resolve ) ) ;
93112 runningBuilds . push ( buildPromise ) ;
94113 }
@@ -101,7 +120,7 @@ async function runTaskPipelines(taskName: string): Promise<Promise<BuildResult>[
101120 return [ ] ;
102121}
103122
104- async function startTestPipeline ( pipeline : BuildDefinitionReference , config = '' ) : Promise < Build > {
123+ async function startTestPipeline ( pipeline : BuildDefinitionReference , config = '' ) : Promise < Build | null > {
105124 console . log ( `Run ${ pipeline . name } pipeline, pipelineId: ${ pipeline . id } ` ) ;
106125
107126 const { BUILD_SOURCEVERSION : branch , CANARY_TEST_NODE_VERSION : nodeVersion } = process . env ;
@@ -117,6 +136,10 @@ async function startTestPipeline(pipeline: BuildDefinitionReference, config = ''
117136 CANARY_TEST_NODE_VERSION : nodeVersion
118137 } ) ;
119138 } catch ( err : any ) {
139+ if ( err . message === 'Could not queue the build because there were validation errors or warnings.' ) {
140+ return null ;
141+ }
142+
120143 err . stack = `Error running ${ pipeline . name } pipeline. Stack: ${ err . stack } ` ;
121144 console . error ( err . stack ) ;
122145 if ( err . response ?. data ) {
0 commit comments