Skip to content

Support multiple 'extends' for a job

Problem to solve

It would be valuable for one job to be able to extend multiple other jobs. Use cases include:

  • Extending templates where you actually already need to use extends to extend a template defined in a file imported using include. Without multiple extends you can't do something like extends: .my-imported-template .my-local-overrides
  • If you want to re-use the same job, with a different configuration. You use a template for the configuration, and another one for the job. Then you use two extends to "include" the job, and the associated configuration (nested extends do not work in this case.)

In general this provides more options for code reuse, which is valuable and a way we want people to implement their pipelines.

Further details

# targets
.master
  only:
  - master
  variables:
    SOME_VAR: some-value

.staging:
  # ...

.develop:
  # ...

# actions
.build:
  tags:
  - docker
  - linux
  script:
  - echo hello world

.test:
  # ...

.deploy:
  # ...

# jobs
build:master:
  extends:
  - .master
  - .build

test:master:
  extends:
  - .master
  - .test

build:staging:
  extends:
  - .master
  - .staging

# ...

Proposal

Support multiple values for the extends key of a job.

What does success look like, and how can we measure that?

One job can extend multiple other jobs.

Links / references

Edited by Jason Yavorsky