概念
持续集成(Continuous integration,简称CI)
频繁地将代码集成到主干。
持续交付(Continuous delivery,简称CD)
持续集成的下一步,频繁地将项目的最新版本,交付给QA团队审核。
持续部署(Continuous deployment,简称CD)
持续交付的下一步,代码通过审核后,自动部署到生产环境。
GitLab-Runner
Install
- 根据官方文档自行选择不同操作系统的安装方式 runner install
Service
/** 查看服务状态 */
gitlab-runner status
/** 启动服务 */
gitlab-runner start
/** 停止服务 */
gitlab-runner stop
/** 重启服务 */
gitlab-runner restart
Runner
/** 查看当前 runner 列表 */
gitlab-runner list
/** 启动 runner */
gitlab-runner run
/** 注册 runner */
gitlab-runner register
/** 注销 runner */
gitlab-runner unregister
/** 校验 runner */
gitlab-runner verify
GitLab CI/CD
All Configuration Reference
Something Special
Environments and deployments
Variables
- Predefined variables (Environment variables)
- .gitlab-ci.yml defined variables
- Secret variables
Artifacts
某个stage的产物,比如运行了打包并压缩出一个zip文件
Cache
download before the job and re-uoload after the job
- policy - pull/push
Tags
select specific Runners to run this project
Anchors
Anchors can be used to duplicate/inherit properties, and is a perfect example to be used with hidden keys to provide templates for your jobs
.job_template: &job_definition # Hidden key that defines an anchor named 'job_definition'
image: ruby:2.1
services:
- postgres
- redis
test1:
<<: *job_definition # Merge the contents of the 'job_definition' alias
script:
- test1 project
test2:
<<: *job_definition # Merge the contents of the 'job_definition' alias
script:
- test2 project
Pipelines triggers
Trigger pipelines through the API.
Submodules
.gitmodules 配置
- 对于在同一个gitlab服务器的项目使用相对路径,ssh等可通用
[submodule "project"]
path = A/project
url = ../../project.git
- 对于不同gitlab服务器的项目是用完整的https路径,注意这要求gitlab-runner所在的机器有获取代码的权限
[submodule "project"]
path = A/project
url = https://git@git-xxxx.xxxx.com/project.git
.gitlab-ci.yml 配置
- gitlab-runner verison > 1.1.0
variables:
// normal、recursive
GIT_SUBMODULE_STRATEGY: recursive
- 低版本
before_script:
- git submodule sync --recursive
- git submodule update --init --recursive