1. 安裝git。
http://git-scm.com/download/win
下載之后一步步安裝即可。
2. 安裝插件。
打開“系統管理” –> “管理插件“-> ”可選插件“。 在”Filter“中輸入”Git“,在搜索出的結果中選中”Git plugin “,點擊“直接安裝”按鈕。
3. 設置git。
1) 安裝完成之后,點開“系統管理” –>“系統設置”。
2) 找到“Git”。點擊“Add Git”按鈕,選擇”Git“。
3) 在 ”Git Name”中輸入一個名字,比如“Jenkins_git”。
在”Path to Git executable”中輸入 git.exe的路徑。比如說“D:\Git\bin\git.exe”。
4) 點擊”應用“,“保存”按鈕。
4. 添加 Credentials。
點擊”系統管理”-> “Manage Credentials”.
點擊“Add Credentials”。 由於我是采用開源中國的git地址,所以選擇“Username with password”. 輸入開源中國的 username 以及 password,比如”xxx“,點擊”Save“。
5. 新建git項目。
點擊“新建”。輸入“Item名稱”,選擇“構建一個自由風格的軟件項目”。
找到”源碼管理“, 選中 ”Git“。
Repository URL : 輸入項目的git地址。
Credentials: 選擇剛剛添加的 Credentials,比如”xxx/****“。
Branches to build: 選擇要build的 分支,比如” */master“。
點擊”應用“,”保存“。
6. 點擊”立即構建“查看構建結果。