1、報錯:SSH: Transferred 0 file(s)
Jenkins搭建過程中,使用 Publish Over SSH 插件。發生 SSH: Transferred 0 file(s)。
百度、google了幾個小時,終於找到答案,特此記錄。
解決方案:
配置:
- Source files
**/*
表示{projectName}這個job的工作目錄下所有的文件和目錄。 - Remove prefix 該操作是針對上面的source files目錄,會移除匹配的目錄。通常留空。
- Remote directory 該操作是基於設定的服務器目錄進行。
- Exec command 遠程服務器執行的命令。例如可以輸出 service jenkins restart 或者 /home/xx. sh 均可。
總結
源文件 不要填絕對路徑,要寫相對路徑。 舉個栗子: 我的jar包路徑是: /var/lib/jenkins/workspace/erp/target/erp.jar 這里要填 target/*。
2、報錯:error=13, 權限不夠
Caused by: hudson.plugins.git.GitException: Error performing git command: /usr/local/git init /usr/local/jenkins/build/workspace/qmflh-h5web-ngx at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2379) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2302) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2298) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1857) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:955) ... 11 more Caused by: java.io.IOException: Cannot run program "/usr/local/git" (in directory "/usr/local/jenkins/build/workspace/qmflh-h5web-ngx"): error=13, 權限不夠 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at hudson.Proc$LocalProc.<init>(Proc.java:250) at hudson.Proc$LocalProc.<init>(Proc.java:219) at hudson.Launcher$LocalLauncher.launch(Launcher.java:937) at hudson.Launcher$ProcStarter.start(Launcher.java:455) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2365) ... 15 more Caused by: java.io.IOException: error=13, 權限不夠 at java.lang.UNIXProcess.<init>(UNIXProcess.java:247) at java.lang.ProcessImpl.start(ProcessImpl.java:134) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 20 more ERROR: Error cloning remote repo 'origin' Finished: FAILURE
這個error=13, 權限不夠的錯誤有很多種情況,留意問題的關鍵詞其實是:
Cannot run program "/usr/local/git" (in directory "/usr/local/jenkins/build/workspace/qmflh-h5web-ngx")
而不是“error=13, 權限不夠”(google半天找不到解決方案)
解決方案:
- go to http://yourjenkinsserver:8080/configureTools/
-
填入git 地址
填寫2的這個地址