Problem with chaining and aggregating jobs

Hi everyone,

I need to chain jobs in a pipeline, but i can’t figure how to do like I want it to work. I have a pipeline like this :

ressources:
# Start of git repo
- name: a1
  type: git
- name: b1
  type: git
- name: b2
  type: git
- name: c1
  type: git
- name: d1
  type: git
- name: d2
  type: git
- name: d3
  type: git
- name: d4
  type: git
- name: d5
  type: git
- name: e1
  type: git
# Start of End of stage Script
- name: end-of-stage-script
  type: git

jobs:
# Start of build jobs
- name: build-a1
  plan:
  - get: a1
    trigger: true
- name: build-b1
  plan:
  - get: b1
    trigger: true
- name: build-b2
  plan:
  - get: b2
    trigger: true
- name: build-c1
  plan:
  - get: c1
    trigger: true
- name: build-d1
  plan:
  - get: d1
    trigger: true
- name: build-d2
  plan:
  - get: d2
    trigger: true
- name: build-d3
  plan:
  - get: d3
    trigger: true
- name: build-d4
  plan:
  - get: d4
    trigger: true
- name: build-d5
  plan:
  - get: d5
    trigger: true
- name: build-e1
  plan:
  - get: e1
    trigger: true
# Start of end of stage jobs
- name: end-of-stage-a
  plan:
  - get: a1
    passed: [a1]
    trigger: true
- name: end-of-stage-b
  plan:
  - get: b1
    passed: [b1, b2]
    trigger: true
  - get: b2
    passed: [b1, b2]
    trigger: true
- name: end-of-stage-c
  plan:
  - get: c1
    passed: [c1]
    trigger: true
- name: end-of-stage-d
  plan:
  - get: d1
    passed: [d1, d2, d3, d4, d5]
    trigger: true
  - get: d2
    passed: [d1, d2, d3, d4, d5]
    trigger: true
  - get: d3
    passed: [d1, d2, d3, d4, d5]
    trigger: true
  - get: d4
    passed: [d1, d2, d3, d4, d5]
    trigger: true
  - get: d5
    passed: [d1, d2, d3, d4, d5]
    trigger: true
- name: end-of-stage-e
  plan:
  - get: e1
    passed: [e1]
    trigger: true

What I need is :

  • If I push in a ressource of a stage, i want to start the associated job, and execute the “end of stage script”
  • I don’t want the “end of stage script” execute until all the builds in the stage are not finished successfully

The “end of stage script” is a script that basically clone the repos of the next stage and update the dependencies version and push (which cause the build of the entire next stage)

I played with various configuration of “passed” properties, buy never found the good configuration, actually my problem is :

  • end of stage is executed only when there is a new version of each ressources in the stage, but if i push in d2 I only need to build d2 before running end of stage
  • end of stage is executed every time, but if i push in c1, end of stage will update all d ressources, and i don’t want to execute end of stage 5 times in a row
  • end of stage is never executed

Can you help me to find the right solution please ?

Regards,

Nicolas.