worker修改
This commit is contained in:
parent
65a5b75a84
commit
f596fd101e
@ -73,7 +73,7 @@ public class OpsTenantAutoConfiguration {
|
|||||||
|
|
||||||
// ========== Security ==========
|
// ========== Security ==========
|
||||||
|
|
||||||
@Bean
|
// @Bean
|
||||||
public FilterRegistrationBean<TenantSecurityWebFilter> tenantSecurityWebFilter(TenantProperties tenantProperties,
|
public FilterRegistrationBean<TenantSecurityWebFilter> tenantSecurityWebFilter(TenantProperties tenantProperties,
|
||||||
WebProperties webProperties,
|
WebProperties webProperties,
|
||||||
GlobalExceptionHandler globalExceptionHandler,
|
GlobalExceptionHandler globalExceptionHandler,
|
||||||
|
@ -34,38 +34,38 @@ public class TargetHandleWorker extends BaseWorker {
|
|||||||
private MachineInfoService machineInfoService;
|
private MachineInfoService machineInfoService;
|
||||||
@Override
|
@Override
|
||||||
public void execute(TaskRunContext context) {
|
public void execute(TaskRunContext context) {
|
||||||
String filePath = "";
|
// String filePath = "";
|
||||||
Map<String, Object> localVariables = context.getLocalVariables();
|
// Map<String, Object> localVariables = context.getLocalVariables();
|
||||||
PipBaseElement taskContextDef = context.getContextDef();
|
// PipBaseElement taskContextDef = context.getContextDef();
|
||||||
if (taskContextDef instanceof PipTask pipTask){
|
// if (taskContextDef instanceof PipTask pipTask){
|
||||||
// 查询并下载目标文件
|
// // 查询并下载目标文件
|
||||||
String pipelineId = pipTask.getPipelineId();
|
// String pipelineId = pipTask.getPipelineId();
|
||||||
//根据流水线id查询流水线信息
|
// //根据流水线id查询流水线信息
|
||||||
PipPipeline pipeline = (PipPipeline) getContextManager().getContext(pipelineId).getContextDef();
|
// PipPipeline pipeline = (PipPipeline) getContextManager().getContext(pipelineId).getContextDef();
|
||||||
//根据目标id查询目标信息
|
// //根据目标id查询目标信息
|
||||||
if (StringUtils.isEmpty(pipeline.getTargetVersionId())){
|
// if (StringUtils.isEmpty(pipeline.getTargetVersionId())){
|
||||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"目标文件不存在");
|
// throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"目标文件不存在");
|
||||||
}
|
// }
|
||||||
TargetVersion targetVersion = targetVersionService.getById(pipeline.getTargetVersionId());
|
// TargetVersion targetVersion = targetVersionService.getById(pipeline.getTargetVersionId());
|
||||||
filePath = targetVersion.getFilePath();
|
// filePath = targetVersion.getFilePath();
|
||||||
File file = new File(filePath);
|
// File file = new File(filePath);
|
||||||
if (!file.exists() || !file.canRead()) {
|
// if (!file.exists() || !file.canRead()) {
|
||||||
log.error("目标文件不存在或不可读");
|
// log.error("目标文件不存在或不可读");
|
||||||
localVariables.put("statusCode", "-1");
|
// localVariables.put("statusCode", "-1");
|
||||||
append(context,"目标文件不存在或不可读");
|
// append(context,"目标文件不存在或不可读");
|
||||||
toBadEnding();
|
// toBadEnding();
|
||||||
}
|
// }
|
||||||
// 上传文件
|
// // 上传文件
|
||||||
String machineId = pipeline.getMachineId();
|
// String machineId = pipeline.getMachineId();
|
||||||
MachineInfo byId = machineInfoService.getById(machineId);
|
// MachineInfo byId = machineInfoService.getById(machineId);
|
||||||
append(context,"开始文件上传");
|
// append(context,"开始文件上传");
|
||||||
try {
|
// try {
|
||||||
SftpUploadUtil.uploadFileViaSftp(byId.getMachineHost(),byId.getSshPort(),byId.getUsername(), CryptogramUtil.doDecrypt(byId.getPassword()),null,file.getAbsolutePath(),"/home/casic/706/ai_test_527",file.getName());
|
// SftpUploadUtil.uploadFileViaSftp(byId.getMachineHost(),byId.getSshPort(),byId.getUsername(), CryptogramUtil.doDecrypt(byId.getPassword()),null,file.getAbsolutePath(),"/home/casic/706/ai_test_527",file.getName());
|
||||||
} catch (SftpUploadUtil.SftpUploadException e) {
|
// } catch (SftpUploadUtil.SftpUploadException e) {
|
||||||
log.error("文件上传失败",e);
|
// log.error("文件上传失败",e);
|
||||||
toBadEnding();
|
// toBadEnding();
|
||||||
}
|
// }
|
||||||
append(context,"文件上传至"+byId.getMachineHost()+" /home/casic/706/ai_test_527");
|
// append(context,"文件上传至"+byId.getMachineHost()+" /home/casic/706/ai_test_527");
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cd.casic.ci.process.engine.worker;
|
package cd.casic.ci.process.engine.worker;
|
||||||
|
|
||||||
|
import cd.casic.ci.common.pipeline.annotation.Plugin;
|
||||||
import cd.casic.ci.process.engine.runContext.TaskRunContext;
|
import cd.casic.ci.process.engine.runContext.TaskRunContext;
|
||||||
import cd.casic.ci.process.engine.worker.base.BaseWorker;
|
import cd.casic.ci.process.engine.worker.base.BaseWorker;
|
||||||
import cd.casic.ci.process.process.dataObject.base.PipBaseElement;
|
import cd.casic.ci.process.process.dataObject.base.PipBaseElement;
|
||||||
@ -8,7 +9,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
//@Plugin(taskType = "test")
|
@Plugin(taskType = "GIT")
|
||||||
public class TestWorker extends BaseWorker {
|
public class TestWorker extends BaseWorker {
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,4 +97,26 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
</path>
|
||||||
|
<path>
|
||||||
|
<groupId>org.mapstruct</groupId>
|
||||||
|
<artifactId>mapstruct-processor</artifactId>
|
||||||
|
<version>${mapstruct.version}</version>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user