reghao 2 mesiacov pred
rodič
commit
16fecb7cfb

+ 2 - 12
web/src/main/java/cn/reghao/bnt/web/devops/deployer/model/po/RemoteHost.java

@@ -1,6 +1,5 @@
 package cn.reghao.bnt.web.devops.deployer.model.po;
 
-import cn.reghao.bnt.web.devops.deployer.model.constant.NodeType;
 import cn.reghao.bnt.web.devops.deployer.model.constant.SshAuthType;
 import cn.reghao.bnt.web.devops.deployer.model.dto.RemoteMachine;
 import cn.reghao.bnt.web.util.BaseEntity;
@@ -73,19 +72,10 @@ public class RemoteHost extends BaseEntity {
         this.remoteAgentConfig = remoteAgentConfig;
     }
 
-    public RemoteHost(String host, String appDir, String appVersion) {
-        this.nodeType = NodeType.mgr.name();
-        this.host = host;
-        this.port = 22;
-        this.appDir = appDir;
-        this.appVersion = appVersion;
-        this.authType = SshAuthType.password.name();
-    }
-
-    public RemoteHost(String host, int port, String authType, String username, String password) {
+    public RemoteHost(String host, int port, String username, String password) {
         this.host = host;
         this.port = port;
-        this.authType = authType;
+        this.authType = SshAuthType.password.name();
         this.username = username;
         this.password = password;
     }

+ 0 - 15
web/src/main/java/cn/reghao/bnt/web/devops/deployer/util/Sftp.java

@@ -1,6 +1,5 @@
 package cn.reghao.bnt.web.devops.deployer.util;
 
-import cn.reghao.bnt.web.devops.deployer.model.constant.SshAuthType;
 import cn.reghao.bnt.web.devops.deployer.model.po.RemoteHost;
 import cn.reghao.bnt.web.devops.deployer.model.UserInfoImpl;
 import cn.reghao.jutil.jdk.io.TextFile;
@@ -287,18 +286,4 @@ public class Sftp {
 
         return shellResult;
     }
-
-    public static void main(String[] args) throws Exception {
-        String host = "192.168.0.108";
-        host = "127.0.0.1";
-        int port = 22;
-        String authType = SshAuthType.password.name();
-        String username = "root";
-        String password = "gsh";
-        RemoteHost remoteHost = new RemoteHost(host, port, authType, username, password);
-        Sftp sftp = new Sftp();
-
-        String command = "docker ps -a";
-        sftp.exec(remoteHost, command);
-    }
 }

+ 15 - 0
web/src/test/java/devops/GitTest.java

@@ -3,6 +3,8 @@ package devops;
 import cn.reghao.bnt.web.devops.build.model.po.RepoAuthConfig;
 import cn.reghao.bnt.web.devops.builder.model.constant.RepoAuthType;
 import cn.reghao.bnt.web.devops.builder.tool.repo.GitImpl;
+import cn.reghao.bnt.web.devops.deployer.model.po.RemoteHost;
+import cn.reghao.bnt.web.devops.deployer.util.Sftp;
 import cn.reghao.jutil.jdk.shell.ShellExecutor;
 import cn.reghao.jutil.jdk.shell.ShellResult;
 import org.eclipse.jgit.api.Git;
@@ -106,4 +108,17 @@ public class GitTest {
             System.out.println(shellResult.getResult());
         }
     }
+
+    @Test
+    public void sftpTest() throws Exception {
+        String host = "127.0.0.1";
+        int port = 22;
+        String username = "root";
+        String password = "gsh";
+        RemoteHost remoteHost = new RemoteHost(host, port, username, password);
+        Sftp sftp = new Sftp();
+
+        String command = "docker ps -a";
+        sftp.exec(remoteHost, command);
+    }
 }