《LINUX教學:構建GitBook并基于GitLab自動發布》要點:
本文介紹了LINUX教學:構建GitBook并基于GitLab自動發布,希望對您有用。如果有疑問,可以聯系我們。
整個GitBook構建過程分為以下幾個部門: 安裝node,npm部署gitbook gitlab版本8以上支持pipelines,服務器上安裝,配置gitlab runner.
1.安裝node
curl?-sL?https://rpm.nodesource.com/setup_6.x?|?bash?-? (6.9.5) yum?install?-y?nodejs
2.安裝gitbook
npm?install?-g?gitbook-cli
3.gitlab-ci實現 gitlab的CI主要通過新版本的pipelines功能. 實現原理: 在部署服務器上運行一個gitlab的runner,并且在gitlab項目的根目錄下創建.gitlab-ci.yml文件,里面主要保留一些運行 腳本,當有新數據被push時,就會執行其中的代碼,實現持續集成. 實現步驟: 1.在項目根目錄下新建.gitlab-ci.yml文件,內容如下
rspec: ? script: ? ? -?gitbook?init ? ? -?gitbook?build ? ? -?sh?start.sh
當項目內容更新時,更新的內容就會pull到部署服務器,然后依次執行上面代碼,完成gitbook的更新. 2.安裝runner到服務器上
#增加gitlab的yum源倉庫 curl?-L?https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh?|?sudo?bash #yum安裝runner yum?install?gitlab-ci-multi-runner
為了把runner添加到gitlab項目中,必要項目的token和gitlab的url,在服務器上運行如下代碼:
gitlab-ci-multi-runner?register Please?enter?the?gitlab-ci?coordinator?URL?(e.g.?https://gitlab.com/): your?url Please?enter?the?gitlab-ci?token?for?this?runner: your?token Please?enter?the?gitlab-ci?description?for?this?runner: [opstest]:? Please?enter?the?gitlab-ci?tags?for?this?runner?(comma?separated): opsdoc? Whether?to?run?untagged?builds?[true/false]: [false]:true? #此處我選擇的是true,否則每次push還得弄tag? Whether?to?lock?Runner?to?current?project?[true/false]: [false]:? Registering?runner...?succeeded
然后根據提示信息輸入,具體的token和url在項目的Settings-->CI/CD Pipelines
下.?然后你就會在面看到你增加的runner了.記得要Whether to run untagged builds [true/false]:選擇true,否則觸發時會卡住~ 理論上建立完畢之后就會部署一次,可在項目路徑下Pipelines--->Pipelines里面查看部署過程.
?
本文永遠更新鏈接地址:
維易PHP培訓學院每天發布《LINUX教學:構建GitBook并基于GitLab自動發布》等實戰技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培養人才。