Skip to content

Commit 7e90e56

Browse files
authored
Merge pull request #766 from topcoder-platform/TSJR-282
When creating a TaaS Job, grab the ID and save it to the data model
2 parents 468ea17 + 8a48727 commit 7e90e56

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ workflows:
154154
- UnitTests
155155
filters:
156156
branches:
157-
only: ['develop', 'connect-performance-testing', 'feature/new-milestone-concept']
157+
only: ['develop', 'connect-performance-testing', 'feature/new-milestone-concept', 'TSJR-282']
158158
- deployProd:
159159
context : org-global
160160
requires:

src/events/projects/postTaasJobs.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import _ from 'lodash';
66
import config from 'config';
77
import axios from 'axios';
8+
import models from '../../models';
89

910
/**
1011
* Create taas job.
@@ -58,11 +59,20 @@ async function createTaasJobsFromProject(req, project, logger) {
5859
workload: _.get(job, 'workLoad.title', '').toLowerCase(),
5960
}).then((createdJob) => {
6061
logger.debug(`jobId: ${createdJob.id} job created with title "${createdJob.title}"`);
62+
/* eslint no-param-reassign: "error" */
63+
job.jobId = createdJob.id;
6164
}).catch((err) => {
6265
logger.error(`Unable to create job with title "${job.title}": ${err.message}`);
6366
}),
6467
),
6568
);
69+
const projectWithJobs = await models.Project.findByPk(project.id);
70+
if (!projectWithJobs) {
71+
logger.error(`Project not found for id ${project.id}, so couldn't save TaaS Job IDs`);
72+
}
73+
projectWithJobs.details.taasDefinition.taasJobs = jobs;
74+
projectWithJobs.changed('details', true);
75+
await projectWithJobs.save();
6676
}
6777

6878
module.exports = createTaasJobsFromProject;

0 commit comments

Comments
 (0)