yamlconcourseconcourse-git-resourceconcourse-s3-resource

How to give same 'get' to multiple jobs in concourse


Instead of giving the same '- get' to multiple jobs, is there any way that I can optimize my code by giving common '- get', if it is allowed in any way.

Currently, I have given the same code (- get) for different jobs

jobs:
- name: Name1
  plan:
  - aggregate:
    - get: anyrepo1
    - get: anyrepo2
  - task: taskhere
    image: anyimage1
    file: file1.yml
- name: Name2
  plan:
  - aggregate:
    - get: anyrepo1
    - get: anyrepo2
  - task: taskhere
    image: anyimage1
    file: file2.yml

I am not getting any error, but want to optimize the code


Solution

  • You can use below code to reuse the same thing again and again. In my case i am using a variable "jobs_get_common".

    `jobs_get_common: &jobs_get_common - get: repo1 - get: repo2

    jobs: - name: Converge-BHS plan: - aggregate: *jobs_get_common - task: anytask image: image1 file: task.yml`