Gitlab中Pipeline语法六

Gitlab中Pipeline语法

needs/include/extends

nodes 阶段并行

- 可以无序执行作业,无序按照阶段顺序运行某些作业,可以让多个阶段同时运行.
- 如果nedds:设置为指向因only/except规则而未实例化的作业,或者不存在,则创建管道时会出现yaml错误.
stages:
  - build
  - test
  - deploy
module-a-build:
  stage: build
  script:
   - echo "hello a"
   - sleep 10

module-b-build:
  stage: build
  script:
    - echo "hello b"
    - sleep 10

module-a-test:
  stage: test
  script:
    - echo "hello test a"
    - sleep 10
  needs: ["module-a-build"]

module-b-test:
  stage: test
  script:
   - echo "hello test b"
   - sleep 10
  needs: ["module-b-build"]

在这里插入图片描述

制品下载

在使用needs,接通过artifacts:true或artifacts:false来控制工件下载,默认为true

module-a-test:
  stage: test
  script:
    - echo "hello a test"
    - sleep 10
  needs:
    - 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-service
  ref: master
  file: '.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: test
  only:
    refs:
      - tags

testjob:
  extends: .tests
  script: echo 'mvn clean test'
  only:
    variables:
      - $RSPEC

合并后

variables:
  RSPEC: 'TEST'
  
testjob:
  stage: test
  script: "mvn clean test"
  only:
    variables:
      - $RSPEC
    refs:
      - tage
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值