Skip to content

Commit

Permalink
Merge pull request #247 from katalon-studio/fix-agent
Browse files Browse the repository at this point in the history
Fix agent
  • Loading branch information
quidl authored Aug 30, 2024
2 parents b555957 + c56d8d2 commit 0cad3c6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/core/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ module.exports = {
requestJob(uuid, organizationId) {
return httpInternal.get(urlParam.requestJob(uuid, organizationId));
},

getJob(jobId) {
return httpInternal.get(urlParam.requestJob(jobId));
},

requestJob(uuid, teamId) {
return httpInternal.get(urlParam.requestJob(uuid, teamId));
},

updateJob(body, apiKey) {
return httpInternal.post(urlParam.updateJob(), body, withAuthorization(apiKey));
Expand Down
4 changes: 4 additions & 0 deletions src/core/api/url-param.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ module.exports = {
return buildUrl({ params }, PATHS.JOB, 'get-job');
},

getJob(jobId) {
return buildUrl({}, PATHS.JOB, jobId);
},

updateJob() {
return buildUrl({}, PATHS.JOB, 'update-job');
},
Expand Down
20 changes: 18 additions & 2 deletions src/service/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,30 @@ class Agent {

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

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

const jobApiKey = parameter.environmentVariables
.find((item) => item.name === jobApiKeyEnv);
const apiKey = jobApiKey ? jobApiKey.value : this.apikey;
const apiKey = jobApiKey ? jobApiKey.value : this.apikey;

let ksArgs;
if (config.isOnPremise) {
Expand Down

0 comments on commit 0cad3c6

Please sign in to comment.