You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`${COMMENT_MARKERS.INVALID_WORK_ITEMS}\n:x: There ${allInvalidWorkItems.length===1 ? 'is' : 'are'}${allInvalidWorkItems.length} work item${allInvalidWorkItems.length===1 ? '' : 's'}${workItemReference} in pull request #${pullNumber} that ${allInvalidWorkItems.length===1 ? 'does' : 'do'} not exist in Azure DevOps. Please verify the work item${allInvalidWorkItems.length===1 ? '' : 's'} and update the commit message${allInvalidWorkItems.length===1 ? '' : 's'} or PR title/body.${workItemList}`,
122
+
COMMENT_MARKERS.INVALID_WORK_ITEMS
123
+
);
124
+
}
125
+
126
+
// Fail if there were any invalid work items
127
+
if(allInvalidWorkItems.length>0){
128
+
core.error(
129
+
`Invalid work item(s): There ${allInvalidWorkItems.length===1 ? 'is' : 'are'}${allInvalidWorkItems.length} work item${allInvalidWorkItems.length===1 ? '' : 's'} that ${allInvalidWorkItems.length===1 ? 'does' : 'do'} not exist in Azure DevOps`
130
+
);
131
+
core.setFailed(
132
+
`There ${allInvalidWorkItems.length===1 ? 'is' : 'are'}${allInvalidWorkItems.length} work item${allInvalidWorkItems.length===1 ? '' : 's'} that ${allInvalidWorkItems.length===1 ? 'does' : 'do'} not exist in Azure DevOps`
133
+
);
134
+
}
85
135
}catch(error){
86
136
core.setFailed(`Action failed with error: ${error}`);
87
137
}
@@ -100,6 +150,7 @@ export async function run() {
100
150
* @param {string} azureDevopsOrganization - Azure DevOps organization name
101
151
* @param {string} azureDevopsToken - Azure DevOps PAT token
@@ -200,7 +251,7 @@ async function checkCommitsForWorkItems(
200
251
core.setFailed(
201
252
`There ${invalidCommits.length===1 ? 'is' : 'are'}${invalidCommits.length} commit${invalidCommits.length===1 ? '' : 's'} in pull request #${pullNumber} not linked to work items`
// All commits are valid - check if there's an existing failure comment to update
@@ -246,49 +297,13 @@ async function checkCommitsForWorkItems(
246
297
}
247
298
}
248
299
249
-
// Handle invalid work items if any were found
300
+
// If invalid work items found, return them (don't comment/fail here - let caller handle it)
250
301
if(invalidWorkItems.length>0){
251
302
consterrorMessage=`Pull request contains ${invalidWorkItems.length===1 ? 'an' : ''} invalid work item${invalidWorkItems.length===1 ? '' : 's'}: ${invalidWorkItems.join(', ')}. ${invalidWorkItems.length===1 ? 'This work item does' : 'These work items do'} not exist in Azure DevOps -- failing operation.`;
252
303
console.log('');
253
304
console.log('');
254
305
console.log(errorMessage);
255
-
core.error(
256
-
`Invalid work item(s): There ${invalidWorkItems.length===1 ? 'is' : 'are'}${invalidWorkItems.length} work item${invalidWorkItems.length===1 ? '' : 's'} that ${invalidWorkItems.length===1 ? 'does' : 'do'} not exist in Azure DevOps`
257
-
);
258
-
259
-
// Add comment to PR if comment-on-failure is true
`${COMMENT_MARKERS.INVALID_WORK_ITEMS}\n:x: There ${invalidWorkItems.length===1 ? 'is' : 'are'}${invalidWorkItems.length} work item${invalidWorkItems.length===1 ? '' : 's'}${workItemReference} in pull request #${pullNumber} that ${invalidWorkItems.length===1 ? 'does' : 'do'} not exist in Azure DevOps. Please verify the work item${invalidWorkItems.length===1 ? '' : 's'} and update the commit message${invalidWorkItems.length===1 ? '' : 's'} or PR title/body.${workItemList}`,
284
-
COMMENT_MARKERS.INVALID_WORK_ITEMS
285
-
);
286
-
}
287
-
288
-
core.setFailed(
289
-
`There ${invalidWorkItems.length===1 ? 'is' : 'are'}${invalidWorkItems.length} work item${invalidWorkItems.length===1 ? '' : 's'} that ${invalidWorkItems.length===1 ? 'does' : 'do'} not exist in Azure DevOps`
@@ -360,6 +375,7 @@ async function checkCommitsForWorkItems(
360
375
* @param {string} azureDevopsOrganization - Azure DevOps organization name
361
376
* @param {string} azureDevopsToken - Azure DevOps PAT token
362
377
* @param {Map} workItemToCommitMap - Map of work item IDs to commit info from checkCommitsForWorkItems
378
+
* @returns {Array} Returns array of invalid work item IDs found in PR title/body
363
379
*/
364
380
asyncfunctioncheckPullRequestForWorkItems(
365
381
octokit,
@@ -458,59 +474,26 @@ async function checkPullRequestForWorkItems(
458
474
}
459
475
}
460
476
461
-
// Handle invalid work items if any were found
477
+
// Return invalid work items if any were found (don't comment/fail here - let caller handle it)
462
478
if(invalidWorkItems.length>0){
463
479
consterrorMessage=`Pull request contains ${invalidWorkItems.length===1 ? 'an' : ''} invalid work item${invalidWorkItems.length===1 ? '' : 's'}: ${invalidWorkItems.join(', ')}. ${invalidWorkItems.length===1 ? 'This work item does' : 'These work items do'} not exist in Azure DevOps -- failing operation.`;
464
480
console.log('');
465
481
console.log('');
466
482
console.log(errorMessage);
467
-
core.error(
468
-
`Invalid work item(s) in PR: There ${invalidWorkItems.length===1 ? 'is' : 'are'}${invalidWorkItems.length} work item${invalidWorkItems.length===1 ? '' : 's'} in the PR that ${invalidWorkItems.length===1 ? 'does' : 'do'} not exist in Azure DevOps`
469
-
);
470
-
471
-
// Add comment to PR if comment-on-failure is true
`${COMMENT_MARKERS.INVALID_WORK_ITEMS}\n:x: There ${invalidWorkItems.length===1 ? 'is' : 'are'}${invalidWorkItems.length} work item${invalidWorkItems.length===1 ? '' : 's'}${workItemReference} in pull request #${pullNumber} that ${invalidWorkItems.length===1 ? 'does' : 'do'} not exist in Azure DevOps. Please verify the work item${invalidWorkItems.length===1 ? '' : 's'} and update the commit message${invalidWorkItems.length===1 ? '' : 's'} or PR title/body.${workItemList}`,
496
-
COMMENT_MARKERS.INVALID_WORK_ITEMS
497
-
);
498
-
}
499
-
500
-
core.setFailed(
501
-
`There ${invalidWorkItems.length===1 ? 'is' : 'are'}${invalidWorkItems.length} work item${invalidWorkItems.length===1 ? '' : 's'} in the PR that ${invalidWorkItems.length===1 ? 'does' : 'do'} not exist in Azure DevOps`
0 commit comments