Published Sep 27, 2016 by Adi Andrea
A few days ago, I was casually looking at the source code of the Google I/O application on GitHub , in the commit list there was a build status that used Travis CI . Travis CI is very integrated with GitHub and has been widely used, so what about Gitlab?
Previously I had never used CI (Continuous Integration), I didn’t even know what it actually was and what its function was. So, after exploring CI, I finally got to know quite a bit, quite a bit, not really know.
Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible. Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly. - Martin Fowler
So in short, CI is an activity in software development that requires all developers to integrate their work results into a repo and from that repo, verification will be carried out with an automatic build, so that if there is an error, it will be known early.
Gitlab is one of the free Git storage services like GitHub. One of its advantages is that we can create private repos for free and as many as possible. So I tend to use Gitlab for projects whose sources should not be known to the public. And of course because Gitlab has a CI system that can be used directly in each repo, the details can be seen here .
Okay, let’s get started, first we setup the repository locally and add the remote to the repo in Gitlab.
Create a file .gitlab-ci.yml
in the root of the Android project, this file is a build configuration file that will be executed by Gitlab CI.
A little explanation about the contents of this file,
image: java:openjdk-8-jdk
used to define the Docker image used, here I use OpenJDK 8.
before_script
we update some dependencies with the commands apt-get
and wget
.
export ANDROID_HOME=$PWD/android-sdk-linux
will create environment variables ANDROID_HOME
.
chmod +x ./gradlew
to make the gradle wrapper script executable.
script
block, the Gradle command will be executed, we can fill it in as needed.
paths
describes the output of the build results that have been carried out.
Do add
, commit
, and push
file .gitlab-ci.yml
. Gitlab will automatically do a build that we can see the progress in the project pipeline section.
We can also see the build log that is running.
This is the display if the build is successful. The build results can also be downloaded directly.
Quite simple and practical, right? example repo can be seen here.