Home:ALL Converter>Match branch names of two Git resources in Concourse CI

Match branch names of two Git resources in Concourse CI

Ask Time:2020-05-07T23:04:18         Author:Vladimir Salin

Json Formatter

I have a Concourse CI pipeline setup that logically depends on two separate Git resources.

For the specific needs, let's say releasing a version m.n.o, the pipeline needs to check out both projects at the same time. Importantly, it needs to refer to the same release/m.n.o in both branches. Furthermore, I'd like my pipeline to be triggered by updating both projects A and B, and of course, the matching branch names requirement should be met e.g. if I update project-a/release/1.2.3, I want Concourse CI to checkout project-b/release/1.2.3 and not any other. It's important to mention, there might be more than one release/m.n.o branch active in both projects i.e. one can push to project-a/release/1.2.3 so that both A & B v.1.2.3 get into CI and then push to project-b/release/2.3.4 so that both A & B v.2.3.4 are built by CI.

resource_types:
  - name: git-multibranch
    type: docker-image
    source:
      repository: cfcommunity/git-multibranch-resource

resources:
  - name: code
    type: git-multibranch
    source:
      uri: [email protected]:project-a.git
      branches: 'release/.*'

  - name: config
    type: git-multibranch
    source:
      uri: [email protected]:project-b.git
      branches: 'release/.*'

jobs:
  - name: build
    plan:
      - get: code
        version: latest
        trigger: true

      - get: config
        version: every
        trigger: true

# ... more stuff

The only stable working solution I found so far is, maintaining the branch name as a variable and switching it every time I need to process the release 1.2.3 or 2.3.4 with fly set-pipeline (or using Vault, but that's even more sophisticated).

Alternatively, I can create two (3, 4, N) pipelines, one for every release version I have. However, I find both options barely satisfactory so far, compared to what can be achieved with other CI/CD engines.

Overall, it feels like I'm missing some basic concept of Concourse that can be used here to achieve a simple goal to checkout two repos having the equally named branch, so I'd really appreciate any help.

Author:Vladimir Salin,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/61661104/match-branch-names-of-two-git-resources-in-concourse-ci
yy