Skip to content

failgracefully/gitlab-ci-build-on-merge-request

 
 

Repository files navigation

gitlab-ci-build-on-merge-request Latest Version

Missing "build on Merge Request" feature of Gitlab CI.

Build is triggered when merge request is first opened and when commits are added to the source branch later on (up until the merge/close event).

Tested on Gitlab CI 8.7.2+.

Setup

  • Start ./gitlab-ci-build-on-merge-request. If you are using docker:
docker run -it --rm --name gitlab-ci-build-on-merge-request \
  shyiko/gitlab-ci-build-on-merge-request:0.3.3 \
  gitlab-ci-build-on-merge-request --url=http://gitlab.example.com --private_token=<authentication token>

Authentication token can be found on Profile Settings -> Account -> Private Token.

  • Now that you have service running:

    • Make sure job definitions in .gitlab-ci.yml file have "triggers" policy enabled (see below).

      build:
        script:
          - ...
        only:
          - master
          - develop
          - /^release-.*$/
          # the line below is required by shyiko/gitlab-ci-build-on-merge-request
          - triggers
    • Create a webhook (go to Project Settings -> Webhooks) that points to gitlab-ci-build-on-merge-request server (e.g. "http://gitlab-ci-build-on-merge-request.example.com/hook") and has "Merge Request events" as a trigger.

    Starting from 0.2.0 private token can also be specified using hook's query parameter "private_token" (see shyiko#2).

That's it.

Building your own Docker image

docker build -t custom-image-name .

Development

PREREQUISITE: go1.6

git clone https://github.com/shyiko/gitlab-ci-build-on-merge-request \
  $GOPATH/src/github.com/shyiko/gitlab-ci-build-on-merge-request
cd $GOPATH/src/github.com/shyiko/gitlab-ci-build-on-merge-request

go build

License

Apache License, Version 2.0

About

Missing "build on Merge Request" feature of Gitlab CI

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 98.1%
  • Dockerfile 1.9%