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