gpt4 book ai didi

gradle - 通过gradle脚本进行SSH

转载 作者:行者123 更新时间:2023-12-03 05:15:55 28 4
gpt4 key购买 nike

我正在使用gradle脚本,我有一个插件可以从 Artifact 自动下载zip,jar和war文件,之后我需要将ssh到远程服务器并将该zip文件移动到特定位置。

我正在尝试以以下方式进行操作,但出现错误

// ------ Tell the script to get dependencies from artifactory ------
buildscript {
repositories {
maven {
url "http://cm.thm.com:80/artifactory/repo1-cache"
url "http://cm.thm.com:80/artifactory/libs-snapshot"
}
}

// ------ Tell the script to get dependencies from artifactory ------
dependencies {
classpath 'org.hidetake:gradle-ssh-plugin:0.4.3'
classpath ([ "com.tr.cm:cmgradleplugin:1.1.118" ])
}
}

apply plugin: 'com.truven.cm.cmgradleplugin'
apply plugin: 'org.hidetake.ssh'
/**
* Use the deploy task to download the artifact and then unzip it to a local directory
* -DjobName specifies the job that produced the artifact
* -DbuildNumber specifies the build Number for the artifact
*/

remotes {
webServer {
host = '10.2.12.912'
user = 'cc'
password = 'tr'
// identity = file('id_rsa')
}
}

task deployment(type: SshTask, dependsOn: deploy){
ssh.run {
session(remotes.webServer) {
put(analytics-engine-AnalyticsLib-4.0.0.78.zip, "/applications/analyticsengine")
execute 'unzip analytics-engine-AnalyticsLib-4.0.0.78.zip'
}
}
}

下面是错误
build file '/applications/jenkins/workspace/DeployArtifactToDev/environments/build.gradle': 43: unexpected token: 0.78 @ line 43, column 45.
analytics-engine-AnalyticsLib-4.0.0.78.zip,
^

1 error

有人可以告诉我我的ssh代码是否正确,还是我需要更改任何内容?

最佳答案

能够为ssh编写代码

// ------ Tell the script to get dependencies from artifactory ------
buildscript {
repositories {
maven {
url "http://c.t.th.com:8/artifactory/repo1-cache"
url "http://c.t.t.com:8/artifactory/libs-snapshot"
}
}

// ------ Tell the script to get dependencies from artifactory ------
dependencies {
classpath 'org.hidetake:gradle-ssh-plugin:1.1.1'
classpath ([ "cm.t.cm:cmgrad:1.1.118" ])
}
}

plugins {
id 'war'
id 'org.hidetake.ssh' version '1.1.1'
}

apply plugin: 'com.truven.cm.cmgradleplugin'
/**
* Use the deploy task to download the artifact and then unzip it to a local directory
* -DjobName specifies the job that produced the artifact
* -DbuildNumber specifies the build Number for the artifact
*/

remotes {
localhost {
host = '1.2.12.1'
user = "$deploy_username"
password = "$deploy_dev_password"
}
}
task deploymenttohost(dependsOn: deploy) << {
ssh.run {
session(remotes.localhost) {
execute 'mkdir /applications/analyticsengine/temp'
put from: 'build/artifacts/*.zip', into: '/applications/analyticsengine/temp'
put from: 'deploymentfiles/*.sh', into: '/applications/analyticsengine/temp'
execute 'unzip -d /applications/analyticsengine/temp/ /applications/analyticsengine/temp/*.zip'
execute 'dos2unix /applications/analyticsengine/temp/analyticsEngine.sh'
execute 'sh /applications/analyticsengine/temp/analyticsEngine.sh'
execute 'pwd'
execute 'rm -fr /applications/analyticsengine/temp'
}
}
}

task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}

而且工作正常

关于gradle - 通过gradle脚本进行SSH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30223973/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com