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+.
- 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.4.0 \
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 togitlab-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 #2).
-
That's it.
docker build -t custom-image-name .
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