Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix agent #260

Merged
merged 11 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/core/api/url-param.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ module.exports = {
},

getJob(jobId) {
return buildUrl({ fields: ['sensitiveData'] }, PATHS.JOB, jobId);
const params = {
fields: 'sensitiveData',
};
return buildUrl({ params }, PATHS.JOB, jobId);
},

updateJob() {
Expand Down
25 changes: 5 additions & 20 deletions src/service/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,6 @@ async function executeJob(jobInfo, keepFiles) {
// ignored
logger.debug('Error when removing tmp directory:', err);
}

// try {
// console.log('QQQQQQ1 tmpDirPath', tmpDirPath);
// console.log('QQQQQQ1 fs', fs);
// fs.rmSync(tmpDirPath, { recursive: true, force: true });
// console.log('QQQQQQ2 tmpDirPath', tmpDirPath);
// } catch (err1) {
// logger.error('Error 2 when removing tmp directory:', err1);
// }
}
}
}
Expand Down Expand Up @@ -398,31 +389,25 @@ class Agent {

// Read job configuration from file
const jobBody = fs.readJsonSync('job.json', { encoding: 'utf-8' });
const { id: jobId } = jobBody;
let { parameter, testProject } = jobBody;
const { id: jobId, testProject } = jobBody;
let { parameter } = jobBody;
let projectId = testProject ? testProject.projectId : undefined;

if (!parameter || !projectId) {
const requestJobResponse = await api.getJob(jobId);
if (!(requestJobResponse && requestJobResponse.body
&& requestJobResponse.body.parameter && requestJobResponse.body.testProject)) {
if (!(requestJobResponse && requestJobResponse.body &&
requestJobResponse.body.parameter && requestJobResponse.body.testProject)) {
// There is no job to execute
return;
}

logger.info(`QQQQQQ0: ${parameter}`);
logger.info(`QQQQQQ1: ${requestJobResponse.body.parameter}`);
if (parameter) {
parameter = { ...requestJobResponse.body.parameter, ...parameter };
logger.info(`QQQQQQ2: ${parameter}`);
} else {
parameter = requestJobResponse.body.parameter
logger.info(`QQQQQQ3: ${parameter}`);
parameter = requestJobResponse.body.parameter;
}
projectId = requestJobResponse.body.testProject.projectId;
logger.info(`QQQQQQ4: ${projectId}`);
}
logger.info(`QQQQQQ5: ${parameter}`);

const jobApiKey = parameter.environmentVariables
.find((item) => item.name === jobApiKeyEnv);
Expand Down
Loading