diff --git a/lib/helper.js b/lib/helper.js index c3d89635..400b70ed 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -267,10 +267,13 @@ async function getManagedBuildClusterName({ annotations, pipeline, isPipelineUpd const buildCluster = findBuildCluster(allBuildClusters, buildClusterName, pipeline.scmContext); if (!buildCluster) { - throw new Error( + const error = new Error( `Cluster specified in screwdriver.cd/buildCluster ${buildClusterName} ` + `for scmContext ${pipeline.scmContext} and group ${groupName} does not exist.` ); + + error.statusCode = 400; + throw error; } if (buildCluster.scmContext !== pipeline.scmContext || !hasClusterAccess(pipeline.name, buildCluster)) { diff --git a/test/lib/buildFactory.test.js b/test/lib/buildFactory.test.js index ee58b6ff..b1c72fdd 100644 --- a/test/lib/buildFactory.test.js +++ b/test/lib/buildFactory.test.js @@ -689,6 +689,7 @@ describe('Build Factory', () => { 'Cluster specified in screwdriver.cd/buildCluster iOS ' + `for scmContext ${scmContext} and group default does not exist.` ); + assert.strictEqual(err.statusCode, 400); }); }); diff --git a/test/lib/pipeline.test.js b/test/lib/pipeline.test.js index 78254647..87fe1767 100644 --- a/test/lib/pipeline.test.js +++ b/test/lib/pipeline.test.js @@ -3213,6 +3213,7 @@ describe('Pipeline Model', () => { 'Cluster specified in screwdriver.cd/buildCluster iOS ' + `for scmContext ${pipeline.scmContext} and group default does not exist.` ); + assert.strictEqual(err.statusCode, 400); }); });