Gitlab中Pipeline语法六
Gitlab中Pipeline语法
needs/include/extends
nodes 阶段并行
- 可以无序执行作业,无序按照阶段顺序运行某些作业,可以让多个阶段同时运行.
- 如果nedds:设置为指向因only/except规则而未实例化的作业,或者不存在,则创建管道时会出现yaml错误.
stages:- build- test- deploy
module-a-build:stage: buildscript:- echo "hello a"- sleep 10module-b-build:stage: buildscript:- echo "hello b"- sleep 10module-a-test:stage: testscript:- echo "hello test a"- sleep 10needs: ["module-a-build"]module-b-test:stage: testscript:- echo "hello test b"- sleep 10needs: ["module-b-build"]
制品下载
在使用needs,接通过artifacts:true或artifacts:false来控制工件下载,默认为true
module-a-test:stage: testscript:- echo "hello a test"- sleep 10needs:- job: "module-a-build"- artifacts: true
如果引入文件中和文件定义的job一样,本地文件会覆盖引入文件
include
可以引入外部yaml文件
使用合并功能可以自定义和覆盖包含本地定义CI/CD配置
include: local 引入本地配置
include:local: 'ci/localci.yaml'
include:file 引入其它项目配置文件
include:#项目名称project: demo/demo/java-serviceref: masterfile: '.gitlab-ci.yml'
remote
通过http/https进行引用远程文件
include:- remote: 'https://github.com/demo-project/master/.gitlab-ci-template.yml'
extends-继承作业配置
stages:- test
variables:RSPEC: 'TEST'.tests:script:echo 'mvn test'stage: testonly:refs:- tagstestjob:extends: .testsscript: echo 'mvn clean test'only:variables:- $RSPEC
合并后
variables:RSPEC: 'TEST'testjob:stage: testscript: "mvn clean test"only:variables:- $RSPECrefs:- tage