From 34c6d6ac445b8cff0e4869257b695523b5cfa2f0 Mon Sep 17 00:00:00 2001 From: "kingapex@javashop.cn" Date: Mon, 19 Apr 2021 17:14:35 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/task/task.ftlh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/templates/task/task.ftlh b/src/main/resources/templates/task/task.ftlh index 8739dde..ead8959 100644 --- a/src/main/resources/templates/task/task.ftlh +++ b/src/main/resources/templates/task/task.ftlh @@ -19,7 +19,7 @@ > + -- Gitee From 642658ef2627dba228e7653810577774ff6e4457 Mon Sep 17 00:00:00 2001 From: "kingapex@javashop.cn" Date: Wed, 21 Apr 2021 11:59:43 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index c8478e1..c09a0e7 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包 -- Gitee From 4cf2fd1de2b22c65205593913c87b72dfe7d408d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B4=A7?= <710916479@qq.com> Date: Tue, 27 Apr 2021 20:21:27 +0800 Subject: [PATCH 3/4] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8Dgit=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E6=88=96=E5=AF=86=E7=A0=81=E5=AD=98=E5=9C=A8@?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E6=97=B6=E4=BB=A3=E7=A0=81=E6=8B=89=E5=8F=96?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=202.=E4=BB=93=E5=BA=93=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E5=A2=9E=E5=8A=A0=E6=97=A0=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/enation/pangu/model/Repository.java | 2 +- .../resources/executor/git_clone/git_clone.sh | 10 +++++--- .../resources/templates/repository/edit.ftlh | 25 ++++++++++++++++++- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/enation/pangu/model/Repository.java b/src/main/java/com/enation/pangu/model/Repository.java index 81c2706..88bc4ce 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/resources/executor/git_clone/git_clone.sh b/src/main/resources/executor/git_clone/git_clone.sh index a5a158a..16f39f4 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 7bde8e5..d9c38bd 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' /> -- Gitee From b41e8a33c500b305006629211db39e626bfe2335 Mon Sep 17 00:00:00 2001 From: "kingapex@javashop.cn" Date: Thu, 29 Apr 2021 16:18:51 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dclone=E6=97=A0=E6=B3=95cl?= =?UTF-8?q?one=E8=87=B3=E7=9B=AE=E6=A0=87=E8=B7=AF=E5=BE=84=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../task/impl/WriteConfigStepExecutor.java | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) 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 cc40855..e92e2a3 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); -- Gitee