2

I have a project where I'd like to use GitLab CI to automate the following:

  1. Confirm that commit at the HEAD of each pushed feature branch passes the tests.
  2. Confirm that each commit within a pushed feature branch properly compiles.

So far I've solved 1 by creating a simple job called my_test_job that successfully runs my tests on every branch push using mvn verify.

How can I solve 2? The command to build the project is mvn package, but I don't know how to have this run on every commit of a pushed branch.

My current gitlab-ci.yml file:

image: maven:3.3.3-jdk-8

stages:
  - test

my_test_job:
  script: mvn verify

tl;dr - I'd like GitLab CI to confirm that each commit within a pushed feature branch compiles without error.

Thanks!

2 Answers2

3

Unfortunately, Gitlab currently cannot be configured to automatically build all commits: https://gitlab.com/gitlab-org/gitlab-ce/issues/14792

Martin
  • 2,754
  • 1
  • 15
  • 35
  • Thanks! That's a shame, but I greatly appreciate the straight forward answer along with a related issue in case it is possible in the future! – disposableme Jun 21 '16 at 15:19
1

Just a thought which I have not personally tried:

You can run a shell script through gitlab-ci.yml which will pick up the branch, check its git log and one by one will checkout each commit and verify if it compiles.

S.K.
  • 3,597
  • 2
  • 16
  • 31
  • Thanks! If I understand you correctly, this would mean that every pushed branch would iterate through and build the *entire* history, including commits that were already built in the past. I think this will technically work, but it would scale very poorly as the repository grows in size. It also would mean that the commits page would not show the build status for the individual commits. – disposableme Jun 21 '16 at 15:25
  • Yes. Its kind of a hack. BTW its possible to get commits specific to only a particular branch. See http://stackoverflow.com/questions/5720343/using-git-show-all-commits-that-exist-only-on-one-specific-branch-and-not-a – S.K. Jun 21 '16 at 16:59