Skip to content

Commit

Permalink
fix: Add template info and prNum to executor start (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkyi authored Oct 26, 2023
1 parent 7159e44 commit b55a016
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
7 changes: 7 additions & 0 deletions config/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const TEMPLATE_NAME = Joi.alternatives()
.description('Name of the Template')
.example('node/npm-install');

const TEMPLATE_FULL_NAME = Joi.string()
.regex(Regex.TEMPLATE_NAME_ALLOW_SLASH)
.max(64)
.description('Full name including namespace of the Template')
.example('node/npm-install');

const TEMPLATE_TAG_NAME = Joi.string()
.regex(Regex.TEMPLATE_TAG_NAME)
.max(30)
Expand Down Expand Up @@ -75,6 +81,7 @@ module.exports = {
template: SCHEMA_TEMPLATE,
namespace: TEMPLATE_NAMESPACE,
name: TEMPLATE_NAME,
fullName: TEMPLATE_FULL_NAME,
templateTag: TEMPLATE_TAG_NAME,
version: TEMPLATE_VERSION,
exactVersion: TEMPLATE_EXACT_VERSION,
Expand Down
20 changes: 17 additions & 3 deletions plugins/executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Joi = require('joi');
const Annotations = require('../config/annotations');
const Job = require('../config/job');
const Provider = require('../config/provider');
const Template = require('../config/template');
const models = require('../models');
const buildId = models.build.base.extract('id').required();
const eventId = models.event.base.extract('id');
Expand All @@ -12,14 +13,25 @@ const jobId = models.job.base.extract('id');
const jobName = models.job.base.extract('name');
const jobState = models.job.base.extract('state');
const jobArchived = models.job.base.extract('archived');
const pipelineId = models.pipeline.base.extract('id');

const SCHEMA_PIPELINE = Joi.object()
.keys({
id: models.pipeline.base.extract('id').required(),
scmContext: models.pipeline.base.extract('scmContext').required()
id: pipelineId.required(),
name: models.pipeline.base.extract('name').optional(),
scmContext: models.pipeline.base.extract('scmContext').required(),
configPipelineId: models.pipeline.base.extract('configPipelineId').required()
})
.unknown();
const SCHEMA_TEMPLATE = Joi.object()
.keys({
id: models.template.base.extract('id'),
fullName: Template.fullName,
name: models.template.base.extract('name'),
namespace: models.template.base.extract('namespace'),
version: models.template.base.extract('version')
})
.unknown();
const pipelineId = models.pipeline.base.extract('id');
const buildSchemaObj = {
build: Joi.object(),
causeMessage,
Expand All @@ -36,12 +48,14 @@ const buildSchemaObj = {
tokenGen: Joi.func(),
pipeline: SCHEMA_PIPELINE,
pipelineId,
template: SCHEMA_TEMPLATE,
buildClusterName: models.buildCluster.base.extract('name'),
container: models.build.base.extract('container').required(),
apiUri: Joi.string().uri().required().label('API URI'),
token: Joi.string().required().label('Build JWT'),
enqueueTime: Joi.date().iso(),
isPR: Joi.boolean().optional().default(true),
prNum: models.event.base.extract('prNum'),
prParentJobId: jobId.optional()
};
const SCHEMA_START = Joi.object()
Expand Down
8 changes: 8 additions & 0 deletions test/data/executor.start.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,13 @@ pipeline:
scmContext: http://mock
admin: admin
token: asdf
name: d2lam/test
template:
id: 888
name: docker
namespace: sd
fullName: sd/docker
version: '1.0.0'
isPR: true
prNum: 567
prParentJobId: 457

0 comments on commit b55a016

Please sign in to comment.