diff --git a/lib/pipeline.js b/lib/pipeline.js index 62c3f210..8b489bcf 100644 --- a/lib/pipeline.js +++ b/lib/pipeline.js @@ -658,11 +658,11 @@ class PipelineModel extends BaseModel { j => !j.name.startsWith(`PR-${prNum}:`) && jobsToCreate.includes(j.name) ); - // create a map for PR Parent Jobs like: {main: 1, publish: 2} + // create a map for PR Parent Jobs like: {main: {id: 1}, publish: {id: 2}} const prParentJobIdMap = {}; prFromPipelineJobs.forEach(j => { - prParentJobIdMap[j.name] = j.id; + prParentJobIdMap[j.name] = j; }); // Create missing PR jobs @@ -677,7 +677,9 @@ class PipelineModel extends BaseModel { // If there is a pr parent if (prParentJobIdMap[jobName]) { - jobModel.prParentJobId = prParentJobIdMap[jobName]; + jobModel.prParentJobId = prParentJobIdMap[jobName].id; + jobModel.templateId = prParentJobIdMap[jobName].templateId; + jobModel.description = prParentJobIdMap[jobName].description; } // Create jobs diff --git a/test/lib/pipeline.test.js b/test/lib/pipeline.test.js index acd5a185..7a04f8d7 100644 --- a/test/lib/pipeline.test.js +++ b/test/lib/pipeline.test.js @@ -182,6 +182,8 @@ describe('Pipeline Model', () => { testJob = getJobMocks({ id: 100, name: 'test', + description: 'test job', + templateId: 5, archived: false }); @@ -1600,7 +1602,9 @@ describe('Pipeline Model', () => { } ], pipelineId: testId, - prParentJobId: 100 + prParentJobId: 100, + templateId: 5, + description: 'test job' }); assert.calledWith( jobFactoryMock.create.secondCall, @@ -1714,7 +1718,9 @@ describe('Pipeline Model', () => { } ], pipelineId: testId, - prParentJobId: 100 + prParentJobId: 100, + templateId: 5, + description: 'test job' }); assert.calledWith( jobFactoryMock.create.secondCall, @@ -1951,7 +1957,9 @@ describe('Pipeline Model', () => { permutations: PARSED_YAML.jobs.main, pipelineId: testId, name: 'PR-2:main', - prParentJobId: 99998 + prParentJobId: 99998, + templateId: undefined, + description: undefined }); }); });