From d8a0e08fe5e10a518ec991427e0694a149af084c Mon Sep 17 00:00:00 2001 From: Tiffany K Date: Sat, 25 May 2024 15:57:18 -0700 Subject: [PATCH] fix(3106): Allow shared.requires for pipeline template yaml --- config/base.js | 3 ++- test/config/base.test.js | 8 +++++++- test/data/config.base.pipelineTemplate-customized.yaml | 8 ++++++++ test/data/config.base.pipelineTemplate.yaml | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 test/data/config.base.pipelineTemplate-customized.yaml diff --git a/config/base.js b/config/base.js index 4966c847..02b7dea0 100644 --- a/config/base.js +++ b/config/base.js @@ -74,7 +74,8 @@ const SCHEMA_CONFIG_PRE_TEMPLATE_MERGE = Joi.object() then: Joi.object().keys({ image: Job.image, environment: Job.environment, - settings: Job.settings + settings: Job.settings, + requires: Job.requires }), otherwise: SCHEMA_SHARED }), diff --git a/test/config/base.test.js b/test/config/base.test.js index 4495bfa5..bd119ca0 100644 --- a/test/config/base.test.js +++ b/test/config/base.test.js @@ -50,12 +50,18 @@ describe('config base', () => { assert.isNull(validate('config.base.pipelineTemplate.yaml', config.base.configBeforeMergingTemplate).error); }); - it('if template is provided then unsupported fields are foridden', () => { + it('if template is provided then unsupported fields are forbidden', () => { assert.isNotNull( validate('config.base.pipelineTemplate-forbidden.yaml', config.base.configBeforeMergingTemplate).error ); }); + it('if template is provided then allow user yaml to customize image, settings, environment, and requires', () => { + assert.isNull( + validate('config.base.pipelineTemplate-customized.yaml', config.base.configBeforeMergingTemplate).error + ); + }); + it('if template is not provided then job is required', () => { assert.isNotNull( validate('config.base.pipelineTemplate-invalid.yaml', config.base.configBeforeMergingTemplate).error diff --git a/test/data/config.base.pipelineTemplate-customized.yaml b/test/data/config.base.pipelineTemplate-customized.yaml new file mode 100644 index 00000000..c1f93eb7 --- /dev/null +++ b/test/data/config.base.pipelineTemplate-customized.yaml @@ -0,0 +1,8 @@ +template: foo/bar@1.0.0 +shared: + image: node:20 + environment: + FOO: user overwrite + settings: + email: foo@example.com + requires: ~commit diff --git a/test/data/config.base.pipelineTemplate.yaml b/test/data/config.base.pipelineTemplate.yaml index 9da863a6..d82cc988 100644 --- a/test/data/config.base.pipelineTemplate.yaml +++ b/test/data/config.base.pipelineTemplate.yaml @@ -5,6 +5,7 @@ shared: FOO: user overwrite settings: email: foo@example.com + requires: ~commit cache: pipeline: ["node_modules/", "~/.sbt"] event: ["target/generated-intermediate-resouce/*"]