我正在尝试创建用于数据加载的自动化管道。我有一种情况,如下所述:
stages
- stage1
- stage2
job1:
stage: stage1
script:
- echo "stage 1 job 1"
job2:
stage: stage1
script:
- echo "stage 1 job 2"
job3:
stage: stage1
script:
- echo "stage 1 job 3"
job4:
stage: stage1
script:
- echo "stage 1 job 4"
我想在同一阶段并行运行job1和job2。因此,在Job1和Job2成功之后
我正在.gitlab-ci.yml中编写管道。
有人可以帮助我实现这一目标吗?
答案 0 :(得分:0)
无法严格执行您的要求(据我所知),作业3和4需要处于单独的阶段(尽管支持将它们置于同一阶段is planned)。需要明确的是:可以满足其他功能要求,即:
关键是使用needs关键字将pipieline转换为directed acyclic graph:
stages:
- stage-1
- stage-2
job-1:
stage: stage-1
needs: []
script:
- echo "job-1 started"
- sleep 5
- echo "job-1 done"
job-2:
stage: stage-1
needs: []
script:
- echo "job-2 started"
- sleep 60
- echo "job-2 done"
job-3:
stage: stage-2
needs: [job-1]
script:
- echo "job-3 started"
- sleep 5
- echo "job-3 done"
job-4:
stage: stage-2
needs: [job-2]
script:
- echo "job-4 started"
- sleep 5
- echo "job-4 done"
如屏幕截图所示,即使作业2仍在运行,作业3也已启动。