Vladimir Salin
Vladimir Salin

Reputation: 3030

Match branch names of two Git resources in Concourse CI

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: git@bitbucket.org:project-a.git
      branches: 'release/.*'

  - name: config
    type: git-multibranch
    source:
      uri: git@bitbucket.org: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.

Upvotes: 0

Views: 718

Answers (1)

bruxelles86
bruxelles86

Reputation: 11

I don't believe there's anything out-of-the-box that can achieve this for you. If I was in a similar position I'd probably use the same pipeline configuration file to set two pipelines in Concourse, using placeholders for the branch names, with the values of those placeholders in two separate variables files.

Upvotes: 1

Related Questions