Concourse merge another branch

1.8k views Asked by At

I'm trying to automate deployments using Concourse-CI.

I have a go application that is checked into a local Gitlab with two branches (master and develop).

I have a pipeline setup for the develop branch that runs go unit tests and if they pass i want to automatically merge the changes from the develop branch to the master branch and tag it with the latest version.

Here is what I have so far:

jobs:
- name: run-unit-tests
  public: true
  plan:
  - get: source-master
  - get: source
    trigger: true
  - put: discord
    params:
      channel: "((channel_id))"
      color: 6076508
      title: Concourse CI
      message: |
        Starting Unit tests for manageGameData
  - task: task-unit-tests
    file: source/ci/tasks/task-unit-tests.yml
    on_success:
      do:
        - put: discord
          params:
            channel: "((channel_id))"
            color: 6076508
            title: Concourse CI
            message: |
              All Unit tests passed for manageGameData
        - put: version
          params: 
            bump: minor
        - get: version
        - put: source-master
          params:
            merge: source
            repository: source-master
            tag: version/number

The problem is that this only tags the master branch with the new version.

Is there a way to merge the develop branch to master?

2

There are 2 answers

1
AdminTome On

I guess i didn't understand the documentation at first but the answer was pretty easy.

- get: source-master
- get: source
- put: source-master
  params:
    repository: source

First you have to get both branches in this case master and develop. Then you push the source local repo (a folder on the concourse worker) to master by using put.

There is no need for the merge parameter and i had the wrong repository parameter.

Hope this helps someone else.

0
Janis Karklins On

Alternatively you could use just scripts for more complex git commands.

 platform: linux

image_resource:
  type: docker-image
  source:
    repository: concourse/buildroot
    tag: git
    run:
      path: /bin/bash
      args:
      - -c
      - |
        set -eux

    git clone https://user:[email protected]

    git config --global user.name "UserName"

    git config --global user.email "[email protected]"

    git checkout master

    git merge hotfix