I just installed Gitlab as repository for my projects and I want to take advantages of their Gitlab CI system. I want to automatically generate a distribution and debug Apk after each commit. I googled but I didn't find anything as a tutorial or similar cases. If someone could guide me in some way, it would be great.
Thanks!
I don't think it's actually necessary. I mean I have the Github app installed - and I think I've used it maybe once and it wasn't all that helpful...
Both Jenkins and Gitlab are designed to serve different requirements. While Jenkins boasts of a large plugin shelf, Gitlab is a comprehensive DevOps tool. While multiple plugins do your job efficiently, integration and management of these plugins might become a challenge when the project scales up.
Make software delivery repeatable and on-demand. GitLab Continuous Integration and Delivery automates all the steps required to build, test and deploy your code to your production environment. Continuous integration automates the builds, provides feedback via code review, and automates code quality and security tests.
GitLab provides Auto DevOps, which are prescribed out-of-the-box CI/CD templates that auto-discover the source code you have. Based on best practices, they automatically detect, build, test, deploy, and monitor your applications.
I've just written a blog post on how to setup Android builds in Gitlab CI using shared runners.
The quickest way would be to have a .gitlab-ci.yml
with the following contents:
image: openjdk:8-jdk variables: ANDROID_TARGET_SDK: "24" ANDROID_BUILD_TOOLS: "24.0.0" ANDROID_SDK_TOOLS: "24.4.1" before_script: - apt-get --quiet update --yes - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 - wget --quiet --output-document=android-sdk.tgz https://dl.google.com/android/android-sdk_r${ANDROID_SDK_TOOLS}-linux.tgz - tar --extract --gzip --file=android-sdk.tgz - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter android-${ANDROID_TARGET_SDK} - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter platform-tools - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter build-tools-${ANDROID_BUILD_TOOLS} - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-android-m2repository - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-google_play_services - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-m2repository - export ANDROID_HOME=$PWD/android-sdk-linux - chmod +x ./gradlew build: script: - ./gradlew assembleDebug artifacts: paths: - app/build/outputs/
This starts off using the Java 8 Docker image, then proceeds to download and install the necessary bits of the Android SDK before your build runs. My post also goes into detail as to how you can build this into a Docker image and host it on Gitlab itself.
Hopefully that helps!
UPDATE - 4/10/2017
I wrote the canonical blog post for setting up Android builds in Gitlab CI back in November '16 for the official Gitlab blog. Includes details on how to run tests and such as well. Linking here.
https://about.gitlab.com/2016/11/30/setting-up-gitlab-ci-for-android-projects/
You can add a build step to your GitLab CI project as below.
gradle assemble
This will generate debug and release APK's of the commit pushed at:
/build/outputs/apk/
You could then write a script to archive the generated APK's however you require.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With