Sign inSign up

ykocaman/gitlab-auto-merge-request

By ykocaman

•Updated almost 8 years ago

Tool to automatically open Merge Requests on GitLab

Image
0

1.2K

ykocaman/gitlab-auto-merge-request repository overview

⁠Open GitLab Merge Requests automatically

Docker Automated buil Docker Pulls Gitlab Project

This script is meant to be used in GitLab CI to automatically open Merge Requests for feature branches, if there is none yet.

The script is provided as dedicated docker image to improve maintainability in the future.

It is based on the script and idea of Riccardo Padovani⁠, which he introduced with his blog post How to automatically create new MR on Gitlab with Gitlab CI⁠. Thanks for providing this.

⁠Instructions

⁠1) GITLAB_PRIVATE_TOKEN

Set a secret variable in your GitLab project with your private token. Name it GITLAB_PRIVATE_TOKEN. This is necessary to raise the Merge Request on your behalf.

⁠2) .gitlab-ci.yml

Add the following to your .gitlab-ci.yml file:

stages:
  - openMr
  - otherStages

Open Merge Request:
  image: tmaier/gitlab-auto-merge-request:1
  before_script: [] # We do not need any setup work, let's remove the global one (if any)
  variables:
    GIT_STRATEGY: none # We do not need a clone of the GIT repository to create a Merge Request
  stage: openMr
  only:
    - /^feature\/*/ # We have a very strict naming convention
  script:
    - merge-request.sh # The name of the script

You can see this in action at .gitlab-ci.yml of this project⁠.

⁠Additional features
  • You can set prefix for your merge request title like "WIP:"
  ...

  variables:
    GIT_STRATEGY: none
    REMOVE_BRANCH_AFTER_MERGE: true # Remove branch after merge
    COMMIT_PREFIX: WIP # Additional prefix
  ...
  • If source and target branch is same then merge request will be fail.

⁠Docker images

The images are hosted on Docker Hub⁠.

Two tags are noteworthy:

  • latest: Latest release on master branch of this project
  • 1: Latest stable release of 1.x version (see note on Semantic Versioning below)

⁠This project is managed on GitLab

The GitHub project⁠ is only a mirror of the GitLab project⁠.

Please open Issues and Merge Requests at the GitLab project⁠.

⁠Versioning

This project follows Semantic Versioning⁠. Following are defined as APIs according to the spec:

  • How to call this script from .gitlab-ci.yml
  • Required Environment Variables

Following are not considered as API according to the spec:

  • Dockerfile and base image used

⁠Authors

Tag summary

Content type

Image

Digest

Size

4.3 MB

Last updated

almost 8 years ago

docker pull ykocaman/gitlab-auto-merge-request