diff --git a/docs/README.md b/docs/README.md index c8478e103c249c0ad99d5c0942fccb5aa38667a4..c09a0e7fdd8cd4061a2d6fefbb42954399e73b5c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -48,9 +48,9 @@ cd pangu mvn clean install -DskipTests ~~~ -> 注意盘古打包完成后不能直接在target目录下使用java -jar 命令运行,因为这时你没有指定数据库的初始文件 +> 注意:基于源码打包后,通过java -jar 运行的话,需要将源码中database目录拷贝到java -jar 执行时的所在目录 > -> 解决方案: 将源码中database文件拷贝到与jar包的同级目录中就可以了 +> 原因:盘古内置了一些示例编排,在database/db文件中,在配置文件中此文件的制定方式为:./database/db ### 运行jar包 diff --git a/src/main/java/com/enation/pangu/model/Repository.java b/src/main/java/com/enation/pangu/model/Repository.java index 81c2706575fff9ae6ed8618a440eb509f426af56..88bc4cee033783023969e33026aa413289d2b577 100644 --- a/src/main/java/com/enation/pangu/model/Repository.java +++ b/src/main/java/com/enation/pangu/model/Repository.java @@ -31,7 +31,7 @@ public class Repository implements Serializable { */ private String address; /** - * 认证类型,可选值:password,publicKey + * 认证类型,可选值:password,publicKey,noAuth */ private String authType; /** diff --git a/src/main/java/com/enation/pangu/task/impl/WriteConfigStepExecutor.java b/src/main/java/com/enation/pangu/task/impl/WriteConfigStepExecutor.java index cc40855a75ce795aa15137cc8566097d09b0f98f..e92e2a3d976cd5622959ac0c86a4996523adf09c 100644 --- a/src/main/java/com/enation/pangu/task/impl/WriteConfigStepExecutor.java +++ b/src/main/java/com/enation/pangu/task/impl/WriteConfigStepExecutor.java @@ -45,11 +45,14 @@ public class WriteConfigStepExecutor implements StepExecutor { private ConfigProjectMapper projectMapper; public static void main(String[] args) { - String target = "${wrokspace}/server/config-server-starup/"; - Map env = new HashMap(); - env.put("workspace", "/opt"); - target = ScriptUtil.renderScript(target, env); - System.out.println(target); + String target = "${wrokspace}/server/config-server-starup/xxxx.properties"; + if (target.indexOf('.')>0) { + System.out.println(true); + String dir = target.substring(0,target.lastIndexOf('/')); + System.out.println(dir); + }else{ + System.out.println(false); + } } @Autowired @@ -70,6 +73,23 @@ public class WriteConfigStepExecutor implements StepExecutor { private boolean writeFile(String projectName, String filename,String target,Map env, SshClient sshClient) { + //目标是否是一个文件 + boolean targetIsFile = false; + String targetFileName = filename; + + //通过判断路径中是否包含'.',来识别目标是否是一个文件 + if (target.indexOf('.')>0) { + targetIsFile = true; + + //如果目标是文件,截取出文件名 + targetFileName = target.substring(target.lastIndexOf('/')+1); + //如果目标是文件,则提取出目录,作为target + target = target.substring(0,target.lastIndexOf('/')); + + }else{ + targetIsFile=false; + } + ConfigProject project = this.getProjectByName(projectName); QueryWrapper queryWrapper = new QueryWrapper() @@ -78,12 +98,13 @@ public class WriteConfigStepExecutor implements StepExecutor { ConfigFile configFile = configFileMapper.selectOne(queryWrapper); String content = configFile.getContent(); - String filePath = getFilePath(projectName, filename); + String filePath = getFilePath(projectName, targetFileName); String absPath = PathUtil.getRootPath() + filePath; File file = new File(absPath); try { sshClient.exec("mkdir -p " + target,text->{}); + //在本地写一个临时文件,以便传输至目标服务器 FileUtils.writeByteArrayToFile(file, content.getBytes(StandardCharsets.UTF_8)); String localPath = "file:" + PathUtil.getRootPath() + filePath; Copy copy = new Copy(); @@ -123,13 +144,11 @@ public class WriteConfigStepExecutor implements StepExecutor { target = ScriptUtil.renderScript(target, env); try { - - //创建目标文件夹 - sshClient.exec("mkdir -p " + target , log -> {}); - //如果是'全部',则copy整个项目文件夹 //否则copy指定文件 if (ALL_FILE_TEXT.equals(file)) { + //创建目标文件夹 + sshClient.exec("mkdir -p " + target , log -> {}); return copyDir(project, sshClient, target, env); }else { return this.writeFile(project ,file, target,env,sshClient); diff --git a/src/main/resources/executor/git_clone/git_clone.sh b/src/main/resources/executor/git_clone/git_clone.sh index a5a158a2a86cd7a2a1851b986362bf63e5964f8d..16f39f4afac6de62fbd9963965549d12e3dc904a 100644 --- a/src/main/resources/executor/git_clone/git_clone.sh +++ b/src/main/resources/executor/git_clone/git_clone.sh @@ -37,14 +37,16 @@ echo '开始clone代码' <#if !git_url?starts_with("http://") && !git_url?starts_with("https://") && !git_url?starts_with("git@") > echo 'git仓库地址格式不正确' -<#elseif repository.authType == 'publickey'> -git clone ${git_url} +<#elseif repository.authType == 'publickey' || repository.authType == 'noAuth'> +git clone ${git_url} --branch ${branch} <#else> <#if username== '' || password == '' > -echo '必须提供仓库的用户名和密码参数' + echo '必须提供仓库的用户名和密码参数' <#else> + <#assign username = username?replace("@","%40")/> + <#assign password = password?replace("@","%40")/> <#assign url = git_url?replace("://","://"+ username+":"+ password +"@") /> -git clone ${url} --branch ${branch} + git clone ${url} --branch ${branch} diff --git a/src/main/resources/templates/repository/edit.ftlh b/src/main/resources/templates/repository/edit.ftlh index 7bde8e5aae07954d72d02edc6c285f562a4084d9..d9c38bd28a750d587d23dc170e09c8175c026f7c 100644 --- a/src/main/resources/templates/repository/edit.ftlh +++ b/src/main/resources/templates/repository/edit.ftlh @@ -39,12 +39,19 @@
-
+
checked value="publickey">
+
+
+ checked value="noAuth"> + +
+
@@ -179,6 +186,9 @@ } else if(authType == 'publickey'){ $("#name-pwd").hide(); $("#public-key").show(); + }else if(authType == 'noAuth'){ + $("#name-pwd").hide(); + $("#public-key").hide(); } } @@ -219,6 +229,19 @@ var pass=document.getElementById("pass"); }); + // 选择无认证 + $("#customRadio3").click(function(){ + var mima=document.getElementById("name-pwd"); + var key=document.getElementById("public-key"); + mima.style.display = "none"; + key.style.display = "none"; + + var name=document.getElementById("u-name"); + name.value = '' + var pass=document.getElementById("pass"); + pass.value = '' + }); + <#include '../common/footer.ftlh' /> diff --git a/src/main/resources/templates/task/task.ftlh b/src/main/resources/templates/task/task.ftlh index 8739dde8dc2b28fc39f861a32d7422d607033f5c..ead89592399df55035fa3c6771e49f68b2d22245 100644 --- a/src/main/resources/templates/task/task.ftlh +++ b/src/main/resources/templates/task/task.ftlh @@ -19,7 +19,7 @@ > +