Bladeren bron

fix: 构建时的信息打印

370774330@qq.com 5 jaren geleden
bovenliggende
commit
7a399b1e9b

+ 2 - 1
core/src/main/java/seecoder/devcloud/core/pipeline/Context.java

@@ -40,7 +40,8 @@ public class Context {
     /**
      * 整个构建流程的记录, 每一个模块的各种运行信息(正常运行的结果,异常信息)都应该写入这里
      */
-    private String result;
+    @Builder.Default
+    private String result = "";
 
     public void appendSuccessResult(String msg){
         result = result + "Success: " + msg + "\n";

+ 2 - 1
core/src/main/java/seecoder/devcloud/core/pipeline/handler/JavaImageBuildHandler.java

@@ -124,9 +124,10 @@ public class JavaImageBuildHandler extends AbstractHandler {
         String imageTag = String.valueOf(new Date().getTime());
         StringBuilder sb = new StringBuilder();
         try {
-            dockerApi.buildAndPush(directory.toString(), "seecoder-devcloud-" + imageName, imageTag, new ProgressHandler() {
+            dockerApi.buildAndPush(directory.toString(), imageName, imageTag, new ProgressHandler() {
                     @Override
                     public void progress(ProgressMessage message) throws DockerException {
+                        System.out.println(message.stream());
                         if (!StringUtils.isEmpty(message.error())) {
                             sb.append(message.error()+"\n");
                         }

+ 1 - 3
core/src/main/java/seecoder/devcloud/core/pipeline/handler/K8sServiceHandler.java

@@ -27,15 +27,13 @@ public class K8sServiceHandler extends AbstractHandler {
         serviceApi = SpringUtil.getBean(ServiceApi.class);
     }
 
-    private Integer port;
-
 
     @Override
     public void process(Context context) throws PipelineException {
 
         //0. 变量准备
         // pod内容器暴露的端口
-        int targetPort =  port;
+        int targetPort = Integer.parseInt(context.getConfigs().get("port"));
         //service对集群内暴露的端口,这里默认与targetPort一致
         int servicePort = targetPort;
 

+ 8 - 3
web/src/main/java/seecoder/devcloud/web/service/impl/pipeline/DeploymentServiceImpl.java

@@ -121,14 +121,19 @@ public class DeploymentServiceImpl implements DeploymentService {
 
         Pipeline pipeline = null;
         try {
-            pipeline = PipelineFactory.init(pipelinePO.getConfigJson(), projectPO.getName(), pipelinePO.getName(),pipelinePO.getTemplateName());
+            pipeline = PipelineFactory.init(pipelinePO.getConfigJson(), projectPO.getUniqueK8sNamespace(), pipelinePO.getName(),pipelinePO.getTemplateName());
             pipeline.start();
             history.setResult("部署成功");
             history.setDetails(pipeline.getContext().getResult());
-        } catch (PipelineException pipelineException) {
+        } catch (PipelineException e) {
             history.setResult("部署失败");
             history.setDetails(pipeline.getContext().getResult());
-            throw new ServiceException(HttpStatus.SC_INTERNAL_SERVER_ERROR,"应用部署失败",pipelineException);
+            throw new ServiceException(HttpStatus.SC_INTERNAL_SERVER_ERROR,"应用部署失败",e);
+        } catch (RuntimeException e){
+            pipeline.getContext().appendErrorResult("运行时错误: ", e);
+            history.setResult("部署失败");
+            history.setDetails(pipeline.getContext().getResult());
+            throw new ServiceException(HttpStatus.SC_INTERNAL_SERVER_ERROR,"应用部署失败",e);
         } finally {
             pipelineHistoryMapper.update(history);
         }

+ 2 - 1
web/src/main/resources/application-wph.yml

@@ -48,10 +48,11 @@ seecoder:
     username: root
     password: rootroot
   docker:
-    host: unix:///var/run/docker.sock
+    host: https://192.168.99.105:2376
     registry: 192.168.99.105:30060
     registryUsername: admin
     registryPassword: admin
+    tls: true