2014-09-21 97 views
2

我使用的是詹金斯與Perforce公司建立一個Maven項目,我需要使用maven釋放插件。我已經配置了我的項目,並且構建工作進展順利,直到我嘗試使用相關的Jenkins插件使用maven release插件。幹運行一切都很順利,但是當試圖發佈時,我得到了這個令人討厭的錯誤消息(下圖)。由於某些原因,Jenkins無法連接到P4服務器。此外,還會檢查「在環境中公開P4PASSWD」。詹金斯和Perforce密碼問題

編輯 - 回答Technext的問題

  • 當你說幹運行,你執行它使用詹金斯只或命令行? 兩個
  • 確切位置在哪裏,你設置P4密碼?在「全局憑據」部分? 在項目配置,在源代碼管理 - > Perforce->密碼
  • 你在哪裏得到的「揭露P4PASSWD環境」的選項? 同一個地方
  • 在上面的日誌中,這條線設置爲P4 "d:\program files\perforce\p4.exe" set密碼? 這一行公開了P4參數 - 所有這些參數(包括P4PASSWD)都已正確設置。我從顯而易見的原因,除去實際值...

這是錯誤消息:

Started by user David 
[EnvInject] - Loading node environment variables. 
Building on master in workspace X:\hudson\jobs\myproject\workspace 
Using master perforce client: myproject 
[workspace] $ "D:\Program Files\Perforce\p4.exe" workspace -o myproject 
[workspace] $ "D:\Program Files\Perforce\p4.exe" login -a -p 
[workspace] $ "D:\Program Files\Perforce\p4.exe" -P *** workspace -o myproject 
Last build changeset: 1062732 
[workspace] $ "D:\Program Files\Perforce\p4.exe" -P *** changes -s submitted -m 1 //myproject/... 
Sync'ing workspace to changelist 1062732 (forcing sync of unchanged files). 
[workspace] $ "D:\Program Files\Perforce\p4.exe" -P *** -s sync -f //myproject/[email protected] 
Sync complete, took 108 ms 
[workspace] $ cmd /c call D:\apache-tomcat-6\temp\hudson368187580614800030.bat 

X:\hudson\jobs\myproject\workspace>"d:\program files\perforce\p4.exe" set 
P4CLIENT=myproject 
P4PASSWD=*** 
P4PORT=*** 
P4USER=*** 

X:\hudson\jobs\myproject\workspace>exit 0 
Parsing POMs 
Downloaded artifact ... 
[workspace] $ D:/ins/Java/jdk1.7.0_10.x64/bin/java -DcreateChecksum=true -cp X:\hudson\plugins\maven-plugin\WEB-INF\lib\maven31-agent-1.4.jar;X:\hudson\tools\hudson.tasks.Maven_MavenInstallation\Maven_3.1.1\boot\plexus-classworlds-2.5.1.jar;X:\hudson\tools\hudson.tasks.Maven_MavenInstallation\Maven_3.1.1/conf/logging jenkins.maven3.agent.Maven31Main X:\hudson\tools\hudson.tasks.Maven_MavenInstallation\Maven_3.1.1 D:\apache-tomcat-6\webapps\hudson\WEB-INF\lib\remoting-2.37.jar X:\hudson\plugins\maven-plugin\WEB-INF\lib\maven31-interceptor-1.4.jar X:\hudson\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.4.jar 51470 
<===[JENKINS REMOTING CAPACITY]===>channel started 
Executing Maven: -B -f X:\hudson\jobs\myproject\workspace\pom.xml -DdevelopmentVersion=0.0.2-SNAPSHOT -DreleaseVersion=0.0.1 -Dresume=false release:prepare release:perform -X 
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 18:22:22+0300) 
Maven home: X:\hudson\tools\hudson.tasks.Maven_MavenInstallation\Maven_3.1.1 
Java version: 1.7.0_10, vendor: Oracle Corporation 
Java home: D:\ins\Java\jdk1.7.0_10.x64\jre 
Default locale: en_US, platform encoding: Cp1252 
OS name: "windows server 2008", version: "6.0", arch: "amd64", family: "windows" 
[INFO] Error stacktraces are turned on. 
[DEBUG] Reading global settings from X:\hudson\tools\hudson.tasks.Maven_MavenInstallation\Maven_3.1.1\conf\settings.xml 
[DEBUG] Reading user settings from C:\...\.m2\settings.xml 
[INFO] Scanning for projects... 
[INFO] Downloading: ... 
[INFO] Downloaded: ... 
[INFO] ------------------------------------------------------------------------ 
[INFO] Reactor Build Order: 
[INFO] 
[INFO] proj-parent 
[INFO] proja 
[INFO] projb 
[INFO] projc 
[INFO] test-reactor 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building test-reactor 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-release-plugin:2.5:prepare (default-cli) @ test-reactor --- 
[INFO] Verifying that there are no local modifications... 
[INFO] ignoring changes on: **\release.properties, **\pom.xml.next, **\pom.xml.releaseBackup, **\pom.xml.backup, **\pom.xml.branch, **\pom.xml.tag 
[INFO] No password found, proceeding without it. 
[DEBUG] SCM path in pom: //depot/myproject 
[DEBUG] Executing: cmd.exe /X /C "p4 -p *** where X:\hudson\jobs\myproject\workspace\pom.xml" 
[DEBUG] Perforce password (P4PASSWD) invalid or unset. 
[DEBUG] cannot find depot => using //depot/myproject 
[DEBUG] Executing cmd.exe /X /C "p4 -d X:\hudson\jobs\myproject\workspace -p *** opened //depot/myproject/..." 
[ERROR] CommandLineException Exit code: 1 - Perforce password (P4PASSWD) invalid or unset. 

編輯2 - 打印環境變量

每Technext要求,我當調用release時,已經打印了相關的P4環境變量:prepare。這些變量都顯示正確的值(這裏是隱藏的),但運行thep4.exe事後聲稱P4PASSWD未設置

[INFO] Executing tasks 
Build sequence for target(s) `main' is [main] 
Complete build sequence is [main, ] 

main: 
    [echo] P4CLIENT [myproject] 
    [echo] P4PASSWD [***] 
    [echo] P4PORT [***] 
    [echo] P4USER [***] 
[INFO] Executed tasks 
Notifying upstream projects of job completion 
Join notifier requires a CauseAction 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building test-reactor 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-release-plugin:2.5:prepare (default-cli) @ test-reactor --- 
[INFO] Verifying that there are no local modifications... 
[INFO] ignoring changes on: **\release.properties, **\pom.xml.next, **\pom.xml.releaseBackup, **\pom.xml.backup, **\pom.xml.branch, **\pom.xml.tag 
[INFO] No password found, proceeding without it. 
[DEBUG] SCM path in pom: //depot/myproject 
[DEBUG] Executing: cmd.exe /X /C "p4 -p *** where ***\pom.xml" 
[DEBUG] Perforce password (P4PASSWD) invalid or unset. 
[DEBUG] cannot find depot => using //depot/myproject 
[DEBUG] Executing cmd.exe /X /C "p4 -d ****\workspace -p *** opened //depot/myproject/..." 
[ERROR] CommandLineException Exit code: 1 - Perforce password (P4PASSWD) invalid or unset. 
+1

當你說'幹run',你執行它使用詹金斯只或_command line_?你到底在哪裏設置P4的密碼?在「全局憑據」部分?你在哪裏可以選擇'在環境中公開P4PASSWD'?由於我幾年前使用Perforce的經驗有限,我記得我們曾經有一個設置,其中一個schedular用於每天在構建箱上設置密碼。在上面的日誌中,這一行是設置P4'「d:\ program files \ perforce \ p4.exe」set'的密碼嗎? – Technext 2014-09-21 12:48:10

+0

@Technext謝謝,請參閱編輯的問題 – 2014-09-21 18:26:25

+0

由於字符限制,我不得不部分分解我的陳述。如果您已經啓用'在環境中公開P4PASSWD',爲什麼要使用'「d:\ program files \ perforce \ p4.exe」set'命令?你是通過批處理文件調用這個_set_命令,還是使用'Build> Add build step> Execute Windows batch command'節? – Technext 2014-09-22 06:29:32

回答

4

最後得到了一個解決方案。 Jenkins perforce插件進行登錄併發布一張票,因此我必須將-Dpassword=${P4TICKET}添加到「發佈目標和選項」字段。它會導致perforce SCM提供商運行帶有-P <P4TICKET>標誌的p4命令。

感謝@Technext的協助。

+0

很高興看到你終於搞定了。請將您的解決方案標記爲答案,以便可以幫助其他人。 :) – Technext 2014-10-01 06:13:41