screwdriver-api 7.0.255 → 7.0.257

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "7.0.255",
3
+ "version": "7.0.257",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -3,6 +3,7 @@
3
3
  const joi = require('joi');
4
4
  const schema = require('screwdriver-data-schema');
5
5
  const idSchema = schema.models.pipeline.base.extract('id');
6
+ const scmUriSchema = schema.models.pipeline.base.extract('scmUri');
6
7
  const listSchema = joi.array().items(schema.models.pipeline.get).label('List of Pipelines');
7
8
  const pipelineIdsSchema = joi.alternatives().try(joi.array().items(idSchema), idSchema).required();
8
9
  const IDS_KEY = 'ids[]';
@@ -21,7 +22,7 @@ module.exports = () => ({
21
22
 
22
23
  handler: async (request, h) => {
23
24
  const { pipelineFactory } = request.server.app;
24
- const { sort, configPipelineId, sortBy, search, page, count } = request.query;
25
+ const { sort, configPipelineId, sortBy, search, scmUri, page, count } = request.query;
25
26
  const scmContexts = pipelineFactory.scm.getScmContexts();
26
27
  let pipelineArray = [];
27
28
 
@@ -55,6 +56,15 @@ module.exports = () => ({
55
56
  // See https://www.w3schools.com/sql/sql_like.asp for syntax
56
57
  keyword: `%${search}%`
57
58
  };
59
+ } else if (scmUri) {
60
+ // The format of scmUri is 'github.com:123:main:source-dir'
61
+ // Search pipelines based on the same repository (include other branch)
62
+ const [scm, id] = scmUri.split(':');
63
+
64
+ config.search = {
65
+ field: 'scmUri',
66
+ keyword: `${scm}:${id}:%`
67
+ };
58
68
  } else {
59
69
  // default list all to 50 max count, according to schema.api.pagination
60
70
  config.paginate = {
@@ -118,7 +128,8 @@ module.exports = () => ({
118
128
  query: schema.api.pagination.concat(
119
129
  joi.object({
120
130
  configPipelineId: idSchema,
121
- 'ids[]': pipelineIdsSchema.optional()
131
+ 'ids[]': pipelineIdsSchema.optional(),
132
+ scmUri: scmUriSchema
122
133
  })
123
134
  )
124
135
  }