安裝注意方面
- 主頁地址 https://www.gocd.io/
- 先安裝JAVA,GOCD建議使用壓縮包的方式進(jìn)行安裝;(如果報(bào)defineclass異常,需要升級java版本)
- 啟動(dòng)默認(rèn)端口http8153、https8154;
使用方面
1. Mac下啟動(dòng)GoAgent時(shí),Agent使用的PATH不是當(dāng)前用戶的PATH,此時(shí)很多比如node,grunt就無法使用,可以使用命令行的方式啟動(dòng),即運(yùn)行/Applications/Go Agent.app/Contents/MacOS/go-agent;
2. Job包含的Task是相互獨(dú)立的,每個(gè)Task改變的環(huán)境變量不會(huì)影響到其他Task;
3. Stage下可以包含多個(gè)Job,Job之間是并行執(zhí)行,任一個(gè)Job失敗,Stage失敗;
4. Job下包含多個(gè)Task,Task是順序執(zhí)行,任一個(gè)失敗,Job失敗;
5. Task執(zhí)行額外命令是,命令名稱不能包含空格,即參數(shù)放入?yún)?shù)輸入框;
6. 16.12版本配置Job不能添加多個(gè)agent resource;
7. 如果需要Job在多個(gè)agent上執(zhí)行,需要在Job配置頁面選擇正確"Run Type";
通過GOCD獲取應(yīng)用生成好的文件,如日志
1. Job配置頁面,Artifacts選項(xiàng)卡,輸入項(xiàng)目的路徑,及生成Artifacts的名稱;
2. 可以創(chuàng)建一個(gè)獲取Artifacts的Job,獲取任一個(gè)Stage生成好的Artifacts;
設(shè)置Pipline的label
<pipeline name="my-material-pipeline" labeltemplate="1.2.${SVN_MATERIAL}">
<materials>
<svn url="http://svn.example.com/" dest="svn" materialName="SVN_MATERIAL" />
</materials>
...
</pipeline>
使用環(huán)境變量
1. 在linux/unix中,sh -c(回車)ls $Environment_Variables
2. windows下,直接使用echo %Environment Variables%,因?yàn)樗忻疃紩?huì)被cmd /c包裝;
3. 在腳本中可以隨意使用;
RESTFull api路徑https://api.gocd.io/current/
基本密碼驗(yàn)證方式
打開"Admin"選項(xiàng)卡,點(diǎn)擊選擇"Server Configuration",在"User Management"部分嚇得"Password File Settings"輸入框中輸入用戶名密碼的properties文件路徑;
密碼是使用SHA1加上base64方式,代碼如下
MessageDigest md = MessageDigest.getInstance("SHA1");
Base64 base64 = new Base64();
byte[] bytes = md.digest(bytes);
String sha1base64 = base64.encodeToString(bytes);//這個(gè)就是encode后的結(jié)果
修改Agent連接的Server地址
GO_SERVER_URL=https://10.203.125.178:8154/go ./agent.sh
一臺機(jī)器上運(yùn)行多個(gè)agent
MacOS
只需要簡單的copy應(yīng)用,即Go Agent.app,再次執(zhí)行如下命令
GO_APPLICATION_NAME="Go Agent 2" /Applications/Go\ Agent\ 2.app/Contents/MacOS/go-agent
Linux
cp /etc/init.d/go-agent /etc/init.d/go-agent-1
sed -i 's/# Provides: go-agent$/# Provides: go-agent-1/g' /etc/init.d/go-agent-1
ln -s /usr/share/go-agent /usr/share/go-agent-1
cp -p /etc/default/go-agent /etc/default/go-agent-1
mkdir /var/{lib,log}/go-agent-1
chown go:go /var/{lib,log}/go-agent-1
windows
1. Copy the installation folder ("C:\Program Files\Go Agent") to "C:\Program Files\Go Agent 2"
2. Delete the file C:\Program Files\Go Agent 2\config\guid.txt
3. Delete the file C:\Program Files\Go Agent 2\.agent-bootstrapper.running
4. Edit wrapper-agent.conf file to customise information related to Go Agent 2 Just after the line #include ../conf/wrapper-license.conf, add
set.GO_AGENT_DIR=C:\Program Files\Go Agent 2
set.GO_AGENT_JAVA_HOME=%GO_AGENT_DIR%\jre
5. Run the following command
6. sc create GoAgent2 binPath= "\"C:\Program Files\Go Agent2\cruisewrapper.exe\" -s \"C:\Program Files\Go Agent2\config\wrapper-agent.conf\""
7. Start "GoAgent2" service
Clean up after canceling a task
在Task配置頁面最下方,可以勾選“On Cancel Task”,并配置額外信息