gitlab--needs、default
needs 并行阶段
stages:
- build
- test
- deploy
module-a-build:
stage: build
script:
- echo "hello3a"
- sleep 10
module-b-build:
stage: build
script:
- echo "hello3b"
- sleep 10
module-a-test:
stage: test
script:
- echo "hello3a"
- sleep 10
module-b-test:
stage: test
script:
- echo "hello3b"
- sleep 10
运行上面的流水线
但现在我们可能需要,当 module-a-build 运行完成之后就运行 module-a-test,当 module-b-build 运行完成之后运行 module-b-test。这时候就需要 needs 了
修改 ci 文件,修改后的如下
stages:
- build
- test
module-a-build:
stage: build
script:
- echo "hello3a"
- sleep 10
module-b-build:
stage: build
script:
- echo "hello3b"
- sleep 30
module-a-test:
stage: test
script:
- echo "hello3a"
- sleep 10
needs: ["module-a-build"] # 当 module-a-build 运行完成之后就运行 module-a-test
module-b-test:
stage: test
script:
- echo "hello3b"
- sleep 10
needs: ["module-b-build"] # 当 module-b-build 运行完成之后就运行 module-b-test
运行流水线
可以查看作业依赖项
点击依赖关系图也可以看到
制品下载
needs
时,可通过artifacts: true
或artifacts: false
module-a-test:
stage: test
script:
- echo "hello3a"
- sleep 10
needs:
- job: "module-a-build"
artifacts: true # 会下载 module-a-build 产生的制品
default
使用 default 可以定义每个 job 的参数,如果 job 里有,会覆盖 default 里的,例如下面的代码
default: # 定义了一个默认的参数
tags: # 如果 job 里没有 tages,就使用这个 tags
- build
retry: # 如果 job 里没有 retry,就使用这个 tags
max: 2
before_script: # 如果 job 里没有 before_script,就使用这个 tags
- echo "before_script"
stages:
- build
- test
build:
stage: build
before_script:
- echo "我是 job 里的"
script:
- echo "我是 build 的 job"
test:
stage: test
script:
- echo "test 的 job"
运行流水线,查看 build 的日志
在来看下 test
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2020-07-04 python--列表,元组
2019-07-04 selenium--等待的三种方式
2019-07-04 postman使用--Monitor