《LINUX教学:构建GitBook并基于GitLab自动发布》要点:
本文介绍了LINUX教学:构建GitBook并基于GitLab自动发布,希望对您有用。如果有疑问,可以联系我们。
整个GitBook构建过程分为以下几个部门: 安装node,npm部署gitbook gitlab版本8以上支持pipelines,服务器上安装,配置gitlab runner.
1.安装node
curl-sLhttps://rpm.nodesource.com/setup_6.x|bash- (6.9.5) yuminstall-ynodejs
2.安装gitbook
npminstall-ggitbook-cli
3.gitlab-ci实现 gitlab的CI主要通过新版本的pipelines功能. 实现原理: 在部署服务器上运行一个gitlab的runner,并且在gitlab项目的根目录下创建.gitlab-ci.yml文件,里面主要保留一些运行 脚本,当有新数据被push时,就会执行其中的代码,实现持续集成. 实现步骤: 1.在项目根目录下新建.gitlab-ci.yml文件,内容如下
rspec: script: -gitbookinit -gitbookbuild -shstart.sh
当项目内容更新时,更新的内容就会pull到部署服务器,然后依次执行上面代码,完成gitbook的更新. 2.安装runner到服务器上
#增加gitlab的yum源仓库 curl-Lhttps://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh|sudobash #yum安装runner yuminstallgitlab-ci-multi-runner
为了把runner添加到gitlab项目中,必要项目的token和gitlab的url,在服务器上运行如下代码:
gitlab-ci-multi-runnerregister Pleaseenterthegitlab-cicoordinatorURL(e.g.https://gitlab.com/): yoururl Pleaseenterthegitlab-citokenforthisrunner: yourtoken Pleaseenterthegitlab-cidescriptionforthisrunner: [opstest]: Pleaseenterthegitlab-citagsforthisrunner(commaseparated): opsdoc Whethertorununtaggedbuilds[true/false]: [false]:true #此处我选择的是true,否则每次push还得弄tag WhethertolockRunnertocurrentproject[true/false]: [false]: Registeringrunner...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全面培养人才。