部署我有以下命令我通過常規執行:找不到命令錯誤時執行行家通過常規
def mavenCommand = "/opt/apache-maven-3.2.2/bin/mvn";
def mavenUrl = "-Durl=${nexusUrl}";
def mavenRepoId = "-DrepositoryId=${nexusRepo}";
def mavenGroupId = "-DgroupId=${groupId}";
def mavenArtefactId = "-DartifactId=${artefactName}";
def mavenVersion = "-Dversion=${artefactVersion}";
def mavenFile = "-Dfile=${fileLocation}";
def mavenPackaging = "-Dpackaging=${artefactExtension}";
uploadToNexus("${mavenCommand} deploy:deploy-file ${mavenUrl} ${mavenRepoId} ${mavenGroupId} ${mavenArtefactId} ${mavenVersion} ${mavenFile} ${mavenPackaging}");
public String uploadToNexus(command){
def uploadToNexusProc = new ProcessBuilder("/bin/sh", "-c","${command}").redirectErrorStream(true).start();
uploadToNexusProc.waitFor();
println uploadToNexusProc.text;
return uploadToNexusProc.exitValue();
}
儘管在這種情況下它上傳到成功的關係,看來最後一個參數總是少不了導致在:
-Dpackaging=zip : command not found
我明白,這是一個shell錯誤,並出於某種原因${mavenPackaging}
擴展到新的生產線。 有人可以幫我理解這個問題的原因嗎?謝謝。
編輯1
$ {mavenPackaging「}是在當我格式化#2碼我出錯了,這是在我的代碼設置正確。現在更新。
EDIT 2
如果我是這樣做:
println "${mavenCommand} deploy:deploy-file ${mavenUrl} ${mavenRepoId} ${mavenGroupId} ${mavenArtefactId} ${mavenVersion} ${mavenFile} ${mavenPackaging}";
我得到以下輸出(其中突出的問題):
/opt/apache-maven-3.2.2/bin/mvn deploy:deploy-file -Durl=http://server/content/repositories/releases -DrepositoryId=nexus -DgroupId=bogus.fake.fakeagain -DartifactId=api -Dversion=1.4.5 -Dfile=/opt/atlassian/jira/temp/api-1.4.5.zip
-Dpackaging=zip
我想你想的'$引號{mavenPackaging「} '在括號外,就像'$ {mavenPackaging}「''在uploadToNexus行末尾一樣。 – zerodiff 2014-09-23 13:14:35
是否有一個原因可以將這裏的殼帶入等式中?你有沒有試過'新的ProcessBuilder(mavenCommand,mavenUrl,mavenRepoId,mavenGroupId,mavenArtefactId,mavenVersion,mavenFile,mavenPackaging)...' – cfrick 2014-09-23 13:27:39
哦,你可以檢查,如果你的'fileLocation'在換行符結束? – cfrick 2014-09-23 13:28:40