feat: ASW-192 playbook支持python 脚本类型
This commit is contained in:
@@ -116,7 +116,7 @@ public class JobPlaybookExecResultChecker extends QuartzJobBean {
|
|||||||
Constants.RUNNING_JOB_THREAD.computeIfAbsent(id, jobId -> startGetJobLogThread(job, environment));
|
Constants.RUNNING_JOB_THREAD.computeIfAbsent(id, jobId -> startGetJobLogThread(job, environment));
|
||||||
break;
|
break;
|
||||||
case "error":
|
case "error":
|
||||||
Constants.RESULT_JOB_THREAD.computeIfAbsent(id, jobId -> startGetJobResultThread(job, environment, RunnerConstant.JobStatus.FAILED.getValue()));
|
Constants.RESULT_JOB_THREAD.computeIfAbsent(id, jobId -> startGetJobResultThread(job, environment,RunnerConstant.JobStatus.FAILED.getValue()));
|
||||||
break;
|
break;
|
||||||
case "done":
|
case "done":
|
||||||
Constants.RESULT_JOB_THREAD.computeIfAbsent(id, jobId -> startGetJobResultThread(job, environment, RunnerConstant.JobStatus.PASSED.getValue()));
|
Constants.RESULT_JOB_THREAD.computeIfAbsent(id, jobId -> startGetJobResultThread(job, environment, RunnerConstant.JobStatus.PASSED.getValue()));
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ public class JobPlaybookExecutor extends QuartzJobBean {
|
|||||||
request.form("file", zipFile);
|
request.form("file", zipFile);
|
||||||
request.form("id", job.getId());
|
request.form("id", job.getId());
|
||||||
request.form("packageName", packageName);
|
request.form("packageName", packageName);
|
||||||
|
request.form("type", playbook.getType());
|
||||||
for (Map.Entry<String, Object> param : params.entrySet()) {
|
for (Map.Entry<String, Object> param : params.entrySet()) {
|
||||||
request.form(param.getKey(), param.getValue());
|
request.form(param.getKey(), param.getValue());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public class PlaybookServiceImpl extends ServiceImpl<PlaybookDao, PlaybookEntity
|
|||||||
FileUtils.copyInputStreamToFile(file.getInputStream(), destination);
|
FileUtils.copyInputStreamToFile(file.getInputStream(), destination);
|
||||||
playbook.setPath(destination.getPath());
|
playbook.setPath(destination.getPath());
|
||||||
if (T.StrUtil.equalsIgnoreCase(type, "airtest_script")){
|
if (T.StrUtil.equalsIgnoreCase(type, "airtest_script")){
|
||||||
|
playbook.setType("airtest_script");
|
||||||
unzip = T.ZipUtil.unzip(destination);
|
unzip = T.ZipUtil.unzip(destination);
|
||||||
List<File> fileList = Arrays.stream(unzip.listFiles()).toList();
|
List<File> fileList = Arrays.stream(unzip.listFiles()).toList();
|
||||||
if (T.CollUtil.isEmpty(fileList) || fileList.size() != 1) {
|
if (T.CollUtil.isEmpty(fileList) || fileList.size() != 1) {
|
||||||
@@ -87,6 +88,17 @@ public class PlaybookServiceImpl extends ServiceImpl<PlaybookDao, PlaybookEntity
|
|||||||
throw new ASWException(RCode.PLAYBOOK_INVALID_FILE);
|
throw new ASWException(RCode.PLAYBOOK_INVALID_FILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (T.StrUtil.equalsIgnoreCase(type, "python")){
|
||||||
|
playbook.setType("python");
|
||||||
|
unzip = T.ZipUtil.unzip(destination);
|
||||||
|
List<File> fileList = Arrays.stream(unzip.listFiles()).toList();
|
||||||
|
fileList = fileList.stream().filter(x -> {
|
||||||
|
return T.StrUtil.equals("main.py", x.getName());
|
||||||
|
}).toList();
|
||||||
|
if (T.CollUtil.isEmpty(fileList)) {
|
||||||
|
throw new ASWException(RCode.PLAYBOOK_INVALID_FILE);
|
||||||
|
}
|
||||||
|
}
|
||||||
this.save(playbook);
|
this.save(playbook);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, "[savePlaybook] [error] [file: {}]", file.getName());
|
log.error(e, "[savePlaybook] [error] [file: {}]", file.getName());
|
||||||
|
|||||||
Reference in New Issue
Block a user