Skip to content

Commit ac3b482

Browse files
committed
When creating a TaaS Job, grab the ID and save it to the data model
https://topcoder.atlassian.net/browse/TSJR-282
1 parent 468ea17 commit ac3b482

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+
job.jobId=createdJob.id
6163
}).catch((err) => {
6264
logger.error(`Unable to create job with title "${job.title}": ${err.message}`);
6365
}),
6466
),
6567
);
68+
const _prj = await models.Project.findByPk(project.id);
69+
if (!_prj) {
70+
logger.error(`Project not found for id ${project.id}, so couldn't save TaaS Job IDs`);
71+
}
72+
_prj.details.taasDefinition.taasJobs = jobs
73+
_prj.changed("details", true)
74+
await _prj.save();
75+
logger.info("Updated project saved:", JSON.stringify(_prj.details.taasDefinition.taasJobs, null, 4))
6676
}
6777

6878
module.exports = createTaasJobsFromProject;

0 commit comments

Comments
 (0)