From 9216862a34e64dc6eaea3fbe5437b399e1f98f93 Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 20 Oct 2023 20:22:53 -0700 Subject: [PATCH] feat: add sonar badge to pipeline (#531) --- models/pipeline.js | 16 +++++++++++++++- test/data/pipeline.yaml | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/models/pipeline.js b/models/pipeline.js index 8d5055d6..12a2d962 100644 --- a/models/pipeline.js +++ b/models/pipeline.js @@ -11,6 +11,13 @@ const Parameters = require('../config/parameters'); const mutate = require('../lib/mutate'); const STATES = ['ACTIVE', 'INACTIVE']; +const BADGE = Joi.object({ + name: Joi.string().max(128).description('The dashboard name for a badge').example('screwdriver/ui'), + uri: Joi.string() + .max(500) + .description('Unique identifier for the badge application dashboard') + .example('https://sonar.screwdriver.cd/dashboard?id=112233') +}); const CREATE_MODEL = { checkoutUrl: Joi.string() @@ -90,7 +97,14 @@ const MODEL = { actions: Joi.array().items(Joi.string()) }) ) - .description('List of subscribed scm urls paired with actions') + .description('List of subscribed scm urls paired with actions'), + + badges: Joi.object({ + sonar: BADGE + }) + .description('A list of badges that pipline has') + .example(`{ sonar: { name: 'dashboard', uri: 'http://sonar.com/sample1' } }`) + .optional() }; const UPDATE_MODEL = { ...CREATE_MODEL, settings: MODEL.settings }; diff --git a/test/data/pipeline.yaml b/test/data/pipeline.yaml index 3dcf800a..c4497d7f 100644 --- a/test/data/pipeline.yaml +++ b/test/data/pipeline.yaml @@ -8,3 +8,7 @@ scmRepo: branch: master url: https://github.com/screwdriver-cd/screwdriver/tree/master state: ACTIVE +badges: + sonar: + name: screwdriver-cd/screwdriver + uri: https://sonar.screwdriver.cd/dashboard?id=123123