@
什么是持續集成
持續集成 Continuous integration ,簡稱CI
隨着軟件開發復雜度的不斷提高,團隊開發成員間如何更好地協同工作以確保軟件開發的質量已經慢慢成為開發過程中不可回避的問題。尤其是近些年來,敏捷(Agile) 在軟件工程領域越來越紅火,如何能在不斷變化的需求中快速適應和保證軟件的質量也顯得尤其的重要。
持續集成正是針對這一類問題的一種軟件開發實踐。它倡導團隊開發成員必須經常集成他們的工作,甚至每天都可能發生多次集成。而每次的集成都是通過自動化的構建來驗證,包括自動編譯、發布和測試,從而盡快地發現集成錯誤,讓團隊能夠更快的開發內聚的軟件。
持續集成具有的特點:
- 它是一個自動化的周期性的集成測試過程,從檢出代碼、編譯構建、運行測試、結果記錄、測試統計等都是自動完成的,無需人工干預;
- 需要有專門的集成服務器來執行集成構建;
- 需要有代碼托管工具支持,例如Git以及可視化界面Gogs的使用
持續集成的作用:
- 保證團隊開發人員提交代碼的質量,減輕了軟件發布時的壓力;
- 持續集成中的任何一個環節都是自動完成的,無需太多的人工干預,有利於減少重復過程以節省時間、費用和工作量;
Jenkins簡介
Jenkins,原名Hudson,2011年改為現在的名字,它 是一個開源的實現持續集成的軟件工具。官方網站:http://jenkins-ci.org/。
Jenkins 能實施監控集成中存在的錯誤,提供詳細的日志文件和提醒功能,還能用圖表的形式形象地展示項目構建的趨勢和穩定性。
特點:
- 易安裝:僅僅兩個docker命令即可從官網下載直接運行,無需額外的安裝,更無需安裝數據庫;
- 易配置:提供友好的GUI配置界面;
- 變更支持:Jenkins能從代碼倉庫(Subversion/CVS)中獲取並產生代碼更新列表並輸出到編譯輸出信息中;
- 支持永久鏈接:用戶是通過web來訪問Jenkins的,而這些web頁面的鏈接地址都是永久鏈接地址,因此,你可以在各種文檔中直接使用該鏈接;
- 集成E-Mail/RSS/IM:當完成一次集成時,可通過這些工具實時告訴你集成結果(據我所知,構建一次集成需要花費一定時間,有了這個功能,你就可以在等待結果過程中,干別的事情);
- JUnit/TestNG測試報告:也就是用以圖表等形式提供詳細的測試報表功能;
- 支持分布式構建:Jenkins可以把集成構建等工作分發到多台計算機中完成;
- 文件指紋信息:Jenkins會保存哪次集成構建產生了哪些jars文件,哪一次集成構建使用了哪個版本的jars文件等構建記錄;
- 支持第三方插件:使得 Jenkins 變得越來越強大
Jenkins安裝與啟動
(1)執行安裝命令,下載jenkins
docker pull jenkins/jenkins
(2)啟動服務
docker run -p 8080:8080 -p 50000:50000 -v /mnt/data/jenkins:/var/jenkins_home --name "jenkins" jenkins/jenkins

若報錯如下:
touch: cannot touch ‘/var/jenkins_home/copy_reference_file.log’: Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
需要修改下目錄權限, 因為當映射本地數據卷時,/mnt/data/jenkins目錄的擁有者為root用戶,而容器中jenkins user的uid為1000
sudo chown -R 1000:1000 /mnt/data/jenkins
(3)訪問鏈接 http://10.20.29.151:8080
若密碼忘記,可進入容器,執行
cat /var/lib/jenkins/secrets/initialAdminPassword獲取初始密碼串。
若目錄不存在,可使用find / -name "initialAdminPassword" -depth -print命令查找。

(4)安裝插件

![[外鏈圖片轉存失敗(img-c6IDumez-1565347998540)(https://raw.githubusercontent.com/SurvivalBoy/Jenkins/master/image/9_2.png)]](/image/aHR0cHM6Ly9pbWdjb252ZXJ0LmNzZG5pbWcuY24vYUhSMGNITTZMeTl5WVhjdVoybDBhSFZpZFhObGNtTnZiblJsYm5RdVkyOXRMMU4xY25acGRtRnNRbTk1TDBwbGJtdHBibk12YldGemRHVnlMMmx0WVdkbEx6bGZNaTV3Ym1j.png)
(5)新建用戶
![[外鏈圖片轉存失敗(img-D6REoIUa-1565347661829)(image/9_3.png)]](/image/aHR0cHM6Ly9pbWdjb252ZXJ0LmNzZG5pbWcuY24vYUhSMGNITTZMeTl5WVhjdVoybDBhSFZpZFhObGNtTnZiblJsYm5RdVkyOXRMMU4xY25acGRtRnNRbTk1TDBwbGJtdHBibk12YldGemRHVnlMMmx0WVdkbEx6bGZNeTV3Ym1j.png)
完成安裝進入主界面
![[外鏈圖片轉存失敗(img-SJ5edM9I-1565348071095)(https://raw.githubusercontent.com/SurvivalBoy/Jenkins/master/image/9_4.png)]](/image/aHR0cHM6Ly9pbWdjb252ZXJ0LmNzZG5pbWcuY24vYUhSMGNITTZMeTl5WVhjdVoybDBhSFZpZFhObGNtTnZiblJsYm5RdVkyOXRMMU4xY25acGRtRnNRbTk1TDBwbGJtdHBibk12YldGemRHVnlMMmx0WVdkbEx6bGZOQzV3Ym1j.png)
Jenkins插件安裝
我們以安裝maven插件為例,演示插件的安裝
(1)點擊左側的“系統管理”菜單 ,然后點擊
![[外鏈圖片轉存失敗(img-IpQajugV-1565348127444)(https://raw.githubusercontent.com/SurvivalBoy/Jenkins/master/image/9_5.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1NTU5MzYzLnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
(2)選擇“可選插件”選項卡,搜索maven,在列表中選擇Maven Integration ,點擊“直接安裝”按鈕
![[外鏈圖片轉存失敗(img-dAcV1sZF-1565347661829)(image/9_6.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1NjE2NjQ4LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
看到如下圖時,表示已經完成
![[外鏈圖片轉存失敗(img-3Ls5a0nh-1565347661829)(image/9_7.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1NjI4OTE1LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
注:如果你的項目是GitHub、GitLib或是Go語言等項目,那么我想你都需要這么一個對應的插件來幫你干活。
全局工具配置
選擇系統管理,全局工具配置
![[外鏈圖片轉存失敗(img-AkQCDHpk-1565347661829)(image/9_88.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1NjM4NTk0LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
自動安裝
Jenkins提供了兩種工具配置的方式,我們還是以maven為例
![[外鏈圖片轉存失敗(img-EfcFjYIx-1565347661830)(image/9_89.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1NjU0MjMyLnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
第一種如上圖,只需要選擇自動安裝和版本號就可以,同時Jenkins在右上角給出了一個解疑按鍵,可以通過該鍵看到說明和示例。
本地安裝
相較於第一種方式,第二種方式相對麻煩一些,但好處是可以在以后打包的時候不必重新下載,縮短打包的時間。
下面就來教大家如何安裝Maven與本地倉庫:
(1)將Maven壓縮包上傳至服務器(虛擬機)
(2)解壓
tar zxvf apache-maven-3.5.4-bin.tar.gz
(3)移動目錄
mv apache-maven-3.5.4 /usr/local/maven
(4)編輯setting.xml配置文件vi /usr/local/maven/conf/settings.xml ,配置本地倉庫目錄,內容如下
<localRepository>/usr/local/repository</localRepository>
(5)將開發環境的本地倉庫上傳至服務器(虛擬機)並移動到/usr/local/repository 。
mv reponsitory_boot /usr/local/repository
其他示例:
(1)JDK配置
![[外鏈圖片轉存失敗(img-ZTavHGdP-1565347661830)(image/9_10.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1NzE2MzU1LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
設置javahome為 /usr/java/jdk1.8.0_171-amd64
(2)Git配置 (本地已經安裝了Git軟件)
![[外鏈圖片轉存失敗(img-f7Y8YIiv-1565347661830)(image/9_11.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1NzI3NDYwLnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
(3)Maven配置
![[外鏈圖片轉存失敗(img-sXlvRKAT-1565347661830)(image/9_12.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1NzM3MTg4LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
代碼上傳至Git服務器
步驟:
(1)在本地安裝git(Windows版本)
(2)在IDEA中選擇菜單 : File -- settings , 在窗口中選擇Version Control -- Git
![[外鏈圖片轉存失敗(img-Pd3N4s7d-1565347661830)(image/8_2.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1NzUyNjg2LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
(3)選擇菜單VCS --> Enable Version Control Integration...
![[外鏈圖片轉存失敗(img-loeXEM3C-1565347661830)(image/8_3.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1ODAyNDI1LnBuZw==.png)
選擇Git
(4)設置遠程地址: 右鍵點擊工程選擇菜單 Git --> Repository -->Remotes...
![[外鏈圖片轉存失敗(img-lMX4ilzk-1565347661831)(image/8_4.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1ODExNjYucG5nP3gtb3NzLXByb2Nlc3M9aW1hZ2Uvd2F0ZXJtYXJrLHR5cGVfWm1GdVozcG9aVzVuYUdWcGRHayxzaGFkb3dfMTAsdGV4dF9hSFIwY0hNNkx5OWliRzluTG1OelpHNHVibVYwTDFOMWNuWnBkbUZzYVhOMFgwSnZlUT09LHNpemVfMTYsY29sb3JfRkZGRkZGLHRfNzA=.png)
![[外鏈圖片轉存失敗(img-JPAagfZo-1565347661831)(image/9_85.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1ODI5MjMyLnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
(5)右鍵點擊工程選擇菜單 Git --> Add
(6)右鍵點擊工程選擇菜單 Git --> Commit Directory...
(7)右鍵點擊工程選擇菜單 Git --> Repository --> Push ...
任務的創建與執行
我們以最火的Java項目和Go項目為例,給大家分別演示如何構建項目和執行
Go項目
(1)回到首頁,點擊新建按鈕 .如下圖,輸入名稱,選擇創建一個自由風格的項目,點擊OK
![[外鏈圖片轉存失敗(img-fuP3U8ij-1565347661831)(image/9_90.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1ODUwMTA1LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
(2)General管理,可以添加項目描述和GitHub項目路徑,以及一些配置
![[外鏈圖片轉存失敗(img-rnQVYGxK-1565347661831)(image/9_91.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1ODU4OTc3LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
(3)源碼管理,選擇GitHub
![[外鏈圖片轉存失敗(img-dcSpzcEm-1565347661831)(image/9_92.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1OTA4NzcyLnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
![[外鏈圖片轉存失敗(img-hoY9FnuX-1565347661831)(image/9_93.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1OTE4NjY1LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
![[外鏈圖片轉存失敗(img-QeNyBQzB-1565347661831)(image/9_94.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1OTI2MjgzLnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
(4)構建觸發器,配置觸發規則,這里以定時和輪詢為示例,配別設置為
![[外鏈圖片轉存失敗(img-yIqFFWiD-1565347661831)(image/9_95.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1OTM1Mzk3LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
定時構建:定時構建1次任務
輪詢SCM:定時查看源碼管理的代碼是否更新,有更新則構建,否則不會構建
如圖所示,定時構建為每間隔10分鍾定時構建一次,輪詢SCM為每5分鍾輪詢檢測一次。
時間*號規則為: 分 時 日 月 周
(5)構建環境,配置控制台輸出時間戳和指定Go語言版本
![[外鏈圖片轉存失敗(img-DQ7BPTdv-1565347661832)(image/9_96.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1OTQ1NDMucG5nP3gtb3NzLXByb2Nlc3M9aW1hZ2Uvd2F0ZXJtYXJrLHR5cGVfWm1GdVozcG9aVzVuYUdWcGRHayxzaGFkb3dfMTAsdGV4dF9hSFIwY0hNNkx5OWliRzluTG1OelpHNHVibVYwTDFOMWNuWnBkbUZzYVhOMFgwSnZlUT09LHNpemVfMTYsY29sb3JfRkZGRkZGLHRfNzA=.png)
(6)構建,使用Shell腳本測試代碼上傳后的項目是否有效
![[外鏈圖片轉存失敗(img-oVj5Ti8j-1565347661832)(image/9_98.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTg1OTU2NjAucG5nP3gtb3NzLXByb2Nlc3M9aW1hZ2Uvd2F0ZXJtYXJrLHR5cGVfWm1GdVozcG9aVzVuYUdWcGRHayxzaGFkb3dfMTAsdGV4dF9hSFIwY0hNNkx5OWliRzluTG1OelpHNHVibVYwTDFOMWNuWnBkbUZzYVhOMFgwSnZlUT09LHNpemVfMTYsY29sb3JfRkZGRkZGLHRfNzA=.png)
Shell如下:
export GOPATH=$WORKSPACE/../ # 指定GOPATH路徑,Go語言執行必須有GOPATH路徑
export GOWORK=$GOPATH/src/github.com/Jenkins # 創建項目執行時的目錄依賴結構
cp -rf $WORKSPACE/* $GOWORK/ # 使測試運行數據和源數據隔離
cd $GOWORK && go build # 進入項目目錄並執行
命令解說:
$GOPATHGo 運行需要指定 GOPATH 也即項目運行路徑
$WORKSPACE/var/jenkins_home/workspace/Jenkins
GOWORK創建符合代碼依賴的執行目錄
注:下載Go的插件在構建時,會自動為我們設置GOROOT,但不會指定GOPATH,因此需要指定
最后點擊“保存”按鈕
(7)執行構建,控制台查看輸出
![[外鏈圖片轉存失敗(img-SuyCn4Pf-1565347661832)(image/9_102.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTkwMDA2ODI3LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
![[外鏈圖片轉存失敗(img-zbSmOZMx-1565347661832)(image/9_101.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTkwMDE0NDY3LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
構建成功,也輸出了WORKSPACE、GOPATH、GOROOT目錄,說明配置生效。進入docker容器或是掛載目錄查看是否有可執行文件:
![[外鏈圖片轉存失敗(img-cwz2yWwm-1565347661833)(image/9_103.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTkwMDI1MzIxLnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
除了上述方法,也可以通過shell配置docker等方式構建、部署、運行項目,還可以將項目配置到當前/其他服務器運行,更多配置方式就不一一陳述了,請自行挖掘。
JAVA項目
(1)回到首頁,點擊新建按鈕 .如下圖,輸入名稱,選擇創建一個Maven項目,點擊OK
![[外鏈圖片轉存失敗(img-0hV0MBjw-1565347661833)(image/9_21.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTkwMDM0MzY0LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
(2)源碼管理,選擇Git
![[外鏈圖片轉存失敗(img-ZmkRZSx5-1565347661834)(image/9_22.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTkwMDQxNTYwLnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
(3)Build
![[外鏈圖片轉存失敗(img-XGQp5hy9-1565347661834)(image/9_23.png)]](/image/aHR0cHM6Ly9pbWctYmxvZy5jc2RuaW1nLmNuLzIwMTkwODA5MTkwMDUyMTA0LnBuZz94LW9zcy1wcm9jZXNzPWltYWdlL3dhdGVybWFyayx0eXBlX1ptRnVaM3BvWlc1bmFHVnBkR2ssc2hhZG93XzEwLHRleHRfYUhSMGNITTZMeTlpYkc5bkxtTnpaRzR1Ym1WMEwxTjFjblpwZG1Gc2FYTjBYMEp2ZVE9PSxzaXplXzE2LGNvbG9yX0ZGRkZGRix0Xzcw.png)
命令:
clean package docker:build -DpushImage
用於清除、打包,構建docker鏡像
最后點擊“保存”按鈕
(4)執行任務
后續請參照Go項目的執行步驟。
注:現已在GitHub上對講義和示例代碼進行開源
