关键字
script | 由Runner执行的Shell脚本。 |
image | 使用docker镜像, image:name |
service | 使用docker services镜像, services:name |
before_script | 执行作业前运行的脚本 |
after_script | 作业完成后运行的脚本 |
stages | 定义管道中的步骤,依次运行 |
stage | 定义管道中步骤的作业段 |
only | 指定作业限制only:refs ,only:kubernetes ,only:variables ,和only:changes |
tags | 指定执行作业的runner |
allow_failure | 让job失败 |
when | 什么时候开始工作,
|
environment | 作业部署到的环境名称 #暂未搞清 |
cache |
key: |
artifacts |
job成功时附加到作业的文件或目录 |
dependencies | 此job依赖其他jobz,主要作用于作业优先级 |
converage | 给定作业代码覆盖率设置 |
retry | 在发生故障时,可以自动重试作业的次数。 |
parallel | 应该并行运行多少个作业实例 |
trigger | 定义下游管道触发器 |
include | 允许此作业包含外部YAML |
extends | 此作业将继承的配置项 |
pages | 上传作业结果用于gitlab pages |
variables | 作业级别定义作业变量 |
单使用示例:
runner的执行方式为shell的简单示例。
1 cache: 2 key:"$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG" #为每分支提供缓存 3 paths: 4 - node_modules #缓存哪些文件/文件夹 5 - bower_components 6 before_script: 7 -echo "执行前运行脚本" 8 after_script: 9 -echo "执行后运行脚本" 10 stages: #设置步骤有哪些,常用三大块,创建,测试,发布 11 -build 12 -test 13 -deploy 14 Job1: #设置某一步的运行工作,每个步骤可有多个job同步进行,也可设置dependencies限制 15 stage:build #此job属于哪个步骤 16 script: 17 -echo "go go go" 18 only: 19 -master #哪个分支触发 20 tags: 21 -share #指定runner,注册runner时填写的tag 22 test: 23 stage:test 24 script: 25 -echo "测试开始" 26 only: 27 -master 28 tags: 29 -share 30 deploy: 31 stage:deploy 32 when: 33 - manual #上面有解释 34 script: 35 -echo "部署开始" 36 only: 37 -master 38 tags: 39 -share