<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Mustafa Khaled</title>
    <description>The latest articles on Forem by Mustafa Khaled (@mustafakhaled).</description>
    <link>https://forem.com/mustafakhaled</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F312207%2F317ab00b-e458-4974-b481-6f79cb7469d7.jpg</url>
      <title>Forem: Mustafa Khaled</title>
      <link>https://forem.com/mustafakhaled</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mustafakhaled"/>
    <language>en</language>
    <item>
      <title>DevOps  - Understanding and applying CI/CD pipeline for Android developers 🚀 - Part 2</title>
      <dc:creator>Mustafa Khaled</dc:creator>
      <pubDate>Mon, 27 Jan 2020 13:55:55 +0000</pubDate>
      <link>https://forem.com/mustafakhaled/devops-understanding-and-applying-ci-cd-pipeline-for-android-developers-part-2-486p</link>
      <guid>https://forem.com/mustafakhaled/devops-understanding-and-applying-ci-cd-pipeline-for-android-developers-part-2-486p</guid>
      <description>&lt;p&gt;Welcome once again 🤗 &lt;br&gt;
I'm pretty sure that you went through &lt;a href="https://dev.to/mustafakhaled/devops-understanding-and-applying-ci-cd-pipeline-for-android-developers-part-1-3o7l"&gt;Part 1&lt;/a&gt;. If not, check it out.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://dev.to/mustafakhaled/devops-understanding-and-applying-ci-cd-pipeline-for-android-developers-part-1-3o7l"&gt;part 1&lt;/a&gt; we managed to implement the first 2 steps : &lt;br&gt;
Step 1: Configure GitLab.&lt;br&gt;
Step 2: Configure fastlane.&lt;/p&gt;

&lt;p&gt;Hold on ... for step 3,&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 3 : Configure FirebaseAppDistribution (Our CD Channel)
&lt;/h4&gt;

&lt;p&gt;As we mentioned in &lt;a href="https://dev.to/mustafakhaled/devops-understanding-and-applying-ci-cd-pipeline-for-android-developers-part-1-3o7l"&gt;part 1&lt;/a&gt;, FirebaseAppDistribution is a tool provided by firebase where you can upload your beta .apk files.&lt;br&gt;
You can find many posts that use Slack channels as their CD channel. For me, it isn't a perfect channel because it's limited to plans, so the free plan has storage of 4 GB for all channels within the workspace, which may limit your apk files to be uploaded.&lt;/p&gt;

&lt;p&gt;So, what makes FirebaseAppDistribution distinctive? 🤔🤔&lt;br&gt;
With FirebaseAppDistribution you can send your beta deployment with a direct E-mail, by mentioning Emails of testers. Also, you can add your release notes of these deployments. Not to mention, a great dashboard for versions uploaded to FirebaseAppDistribution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LmcJ15Mu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/sfbj92w0z8086womra0c.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LmcJ15Mu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/sfbj92w0z8086womra0c.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To do so, there are 3 steps &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Create android firebase application.&lt;/strong&gt;&lt;br&gt;
Because firebase documentation is outstanding 🤩🤩, we should follow &lt;a href="https://firebase.google.com/docs/android/setup/"&gt;it&lt;/a&gt;.&lt;br&gt;
Also, don't forget to &lt;strong&gt;Get Started&lt;/strong&gt; with FirebaseAppDistribution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6ViYauOi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/74y8om1332btuu5ztm03.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6ViYauOi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/74y8om1332btuu5ztm03.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b. Install firebase cli to your machine.&lt;/strong&gt;&lt;br&gt;
Because we are going to use firebase commands that would help us in uploading beta deployments. Following firebase &lt;a href="https://firebase.google.com/docs/cli"&gt;documentation&lt;/a&gt; we would manage to install firebase cli.&lt;/p&gt;

&lt;p&gt;c. check firebase is installed correctly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;firebase &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  Step 4 : Fastfile
&lt;/h4&gt;

&lt;p&gt;Now, it's time to write the steps that fastlane would follow to upload our beta deployments to FirebaseAppDistruibution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
 desc &lt;span class="s2"&gt;"Submit a new beta build to Firebase App Distribution"&lt;/span&gt;
    lane : distribute &lt;span class="k"&gt;do
        &lt;/span&gt;build_android_app&lt;span class="o"&gt;(&lt;/span&gt;
          task: &lt;span class="s2"&gt;"assemble"&lt;/span&gt;,
          build_type: &lt;span class="s2"&gt;"debug"&lt;/span&gt;
        &lt;span class="o"&gt;)&lt;/span&gt;

        firebase_app_distribution&lt;span class="o"&gt;(&lt;/span&gt;
            app: &lt;span class="s2"&gt;"replace this with app Id. Go to Firebase console -&amp;gt;     Project Overview -&amp;gt; Project Setting"&lt;/span&gt;,
            testers: &lt;span class="s2"&gt;"example1@domain.com,     example2@domain.com"&lt;/span&gt;,
            firebase_cli_token: &lt;span class="s2"&gt;"firebase token"&lt;/span&gt;

        &lt;span class="o"&gt;)&lt;/span&gt;

      end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In fastlane, it contains &lt;strong&gt;lanes&lt;/strong&gt; where lane is a specific task in fastlane.&lt;br&gt;
We have a lane called &lt;strong&gt;distribute&lt;/strong&gt; that would build a debug apk, and by using &lt;strong&gt;firebase_app_distribution&lt;/strong&gt; it would upload the apk to the specific app in firebase console.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;app&lt;/strong&gt;: As mentioned earlier, go to firebase console -&amp;gt; Project Overview -&amp;gt; Project Setting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;testers&lt;/strong&gt;: Define testers emails separted by ","&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;firebase_cli_token&lt;/strong&gt;: This token required for distribution process, so how could we get this token? 🤔🤔&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open your terminal&lt;/li&gt;
&lt;li&gt;run the following command
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;firebase login:ci
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Open the link&lt;/li&gt;
&lt;li&gt;Choose the account where your project is rest&lt;/li&gt;
&lt;li&gt;Allow permissions for firebase&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now you can see the token generated for firebase cli 🎉🚀&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NuawUZHd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/areqtcpsjxyjysngngeq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NuawUZHd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/areqtcpsjxyjysngngeq.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remark&lt;/strong&gt;: Please commit&amp;amp;push changes in fastfile. 👌&lt;/p&gt;

&lt;p&gt;Now, let's run this task from the android studio terminal ... we run lane by keyword &lt;strong&gt;fastlane&lt;/strong&gt; followed by the lane name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;fastlane distribute
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Oh 😔😔 , seems like you got some error like that : &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T5o_uH96--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/tqu1m3gjii736deatiwj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T5o_uH96--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/tqu1m3gjii736deatiwj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fortunately, the error is very descriptive. fastlane doesn't know what  &lt;strong&gt;firebase_app_distribution&lt;/strong&gt; is.&lt;/p&gt;

&lt;p&gt;Here is the role of &lt;strong&gt;Gemfile&lt;/strong&gt; mentioned previously. We should add firebase_app_distribution as a dependency for fastlane.&lt;br&gt;
So from android studio terminal, add firebase_app_distribution plugin.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;fastlane add_plugin firebase_app_distribution
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Remark:&lt;/strong&gt; New files would be generated within fastlane directory of your android project after adding this plugin, So make sure committing &amp;amp; pushing changes&lt;/p&gt;

&lt;p&gt;Now, everything is up and running, give another try&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;fastlane distribute
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wohooooo 🎉🎉 We did a great job, please check your emails listed in fastfile to ensure that an Email has been sent with an invitation. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/ckeHl52mNtoq87veET/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/ckeHl52mNtoq87veET/giphy.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Great Job 🤓, let's make this automating 🚀 this using GitLab CI/CD pipeline. Our goal now is when you push to your origin branch, i.e dev, master , etc... . The pipeline should start its stages.
&lt;/h4&gt;




&lt;h4&gt;
  
  
  Step 5: Configure gitlab-ci.yml
&lt;/h4&gt;

&lt;p&gt;You can find gitlab-ci.yml in the root of your android project. so here is the question. What is the gitlab-ci.yml file?&lt;br&gt;
cool, gitlab-ci.yml is a file defines the structure and order of the pipelines. &lt;br&gt;
As we mentioned earlier, our pipeline consists of &lt;strong&gt;3 stages&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;build&lt;/li&gt;
&lt;li&gt;test&lt;/li&gt;
&lt;li&gt;deploy
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;     &lt;span class="s"&gt;mustafakhaled/android-fastlane-firebase:1.0&lt;/span&gt;

&lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;

&lt;span class="na"&gt;lintDebug&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint&lt;/span&gt;

&lt;span class="na"&gt;assembleDebug&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./gradlew assembleDebug&lt;/span&gt;
  &lt;span class="na"&gt;artifacts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;app/build/outputs/&lt;/span&gt;

&lt;span class="na"&gt;debugTests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./gradlew -Pci --console=plain :app:testDebug&lt;/span&gt;

&lt;span class="na"&gt;deploy_internal&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;


  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;

  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;fastlane distribute&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Maybe seems like weird syntax, but don't worry we will go through this file in details 😄😁.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;     &lt;span class="s"&gt;mustafakhaled/android-fastlane-firebase:1.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we mentioned in &lt;a href="https://dev.to/mustafakhaled/devops-understanding-and-applying-ci-cd-pipeline-for-android-developers-part-1-3o7l"&gt;part 1&lt;/a&gt;, &lt;br&gt;
&lt;strong&gt;Docker:&lt;/strong&gt; it is a containerization tool that allows a developer to package up an application with all of the parts it needs.&lt;br&gt;
I wrapped up all parts need for our application in a docker image, where we can use it in our continuous integration.You can check it out in &lt;a href="https://hub.docker.com/repository/docker/mustafakhaled/android-fastlane-firebase"&gt;Dokcer Hub&lt;/a&gt;. &lt;br&gt;
This image contains basic tools that serve our main goal. it contains: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linux&lt;/li&gt;
&lt;li&gt;Android SDK&lt;/li&gt;
&lt;li&gt;Fastlane&lt;/li&gt;
&lt;li&gt;Firebase tools&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you think about it, you would find this environment is like your machine environment where you were able to build and send your app to firebaseAppDistrubution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this part, we just define the stages of the pipeline.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;
&lt;span class="na"&gt;lintDebug&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This job is run on build stage, it run &lt;strong&gt;lint&lt;/strong&gt; check. It helps find poorly structured code that can impact the reliability and efficiency of your Android apps and make your code harder to maintain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;assembleDebug&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./gradlew assembleDebug&lt;/span&gt;
  &lt;span class="na"&gt;artifacts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;app/build/outputs/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This job is on the build stage also. It's responsible for building debug apk. you could find &lt;strong&gt;artifacts&lt;/strong&gt;, it is a list of files and directories to attach to a job on success.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;debugTests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./gradlew -Pci --console=plain :app:testDebug&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This job is on the test stage. It 's responsible for run unit tests if found in your projects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;

  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;fastlane distribute&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This job is on the deploy stage. It's responsible to deploy your beta deployment to firebaseAppDistribution as we accomplished it locally(without CI).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enhancement&lt;/strong&gt;: We want this pipeline to run only if I pushed to &lt;strong&gt;master&lt;/strong&gt; branch, not all branches. This could be done in gitlab-ci.yml by modifying stage of deploy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;deploy&lt;/span&gt;

  &lt;span class="na"&gt;only&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;master&lt;/span&gt;

  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;fastlane distribute&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Remark&lt;/strong&gt;: You can define any branch you want.&lt;/p&gt;

&lt;h5&gt;
  
  
  The last step is to push your gitlab-ci.yml and your pipeline would start.
&lt;/h5&gt;

&lt;p&gt;Open GitLab, your pipeline should be like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6g0ps5iW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/6g17svsg6zpitra0y4s2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6g0ps5iW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/6g17svsg6zpitra0y4s2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wait for the pipeline.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/tXL4FHPSnVJ0A/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/tXL4FHPSnVJ0A/giphy.gif" alt="Wait"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  WOHOOOOOOOOO .. Finally ! 🎉🎉🎉🎉🎉🎉🎉🎉
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pJky1xBE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/a3b4x9h3aeqisvfosedv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pJky1xBE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/a3b4x9h3aeqisvfosedv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Celebrate 🎉🎉🎉🎉💃💃💃💃 .. Now you automated your beta deployments to testers emails with no hassle. 🚀🚀🚀🚀&lt;/p&gt;

&lt;p&gt;Check the full repository on my &lt;a href="https://gitlab.com/MustafaKhaled/gitlab-cicd-fastlane-firebaseappdistribution"&gt;GitLab&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Waiting for your feedback 😄😄 in the comments below and for any questions as well. &lt;/p&gt;

&lt;p&gt;Reach me out through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Email: &lt;a href="mailto:mustafakhaledmustafa@outlook.com"&gt;mustafakhaledmustafa@outlook.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/MustafaKhaled"&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Twitter : &lt;a href="https://twitter.com/Mus_Khaled"&gt;@mus_khaled&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gitlab</category>
      <category>firebaseappdistribution</category>
      <category>fastlane</category>
      <category>android</category>
    </item>
    <item>
      <title>DevOps  - Understanding and applying CI/CD pipeline for Android developers 🚀 - Part 1</title>
      <dc:creator>Mustafa Khaled</dc:creator>
      <pubDate>Mon, 27 Jan 2020 13:26:24 +0000</pubDate>
      <link>https://forem.com/mustafakhaled/devops-understanding-and-applying-ci-cd-pipeline-for-android-developers-part-1-3o7l</link>
      <guid>https://forem.com/mustafakhaled/devops-understanding-and-applying-ci-cd-pipeline-for-android-developers-part-1-3o7l</guid>
      <description>&lt;p&gt;As an Android Engineer, think about how much time wasted in deploying an APK for testers? ⌛️&lt;br&gt;
It may be done in many steps, check your project compiled, run unit test, start generating your .apk file, then upload it to a third party (e.g. fabric.com, diawi.com, etc ..). After that, you should notify the testers that your build is ready for testing. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/NWg7M1VlT101W/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/NWg7M1VlT101W/giphy.gif" alt="Yes I got tired"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yes, I got tired while describing 😭. Of course, this is a huge time waster. As this process may be repeated throughout the workday.&lt;/p&gt;

&lt;p&gt;With CI/CD, the problem would be solved easily. 🎉🎉&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/5z0cCCGooBQUtejM4v/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/5z0cCCGooBQUtejM4v/giphy.gif" alt="Problem has been Solved"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, what is CI/CD in a nutshell? &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Continuous integration (CI) and continuous delivery (CD) embody a culture, set of operating principles, and collection of practices that enable application development teams to deliver code changes more frequently and reliably. The implementation is also known as the CI/CD pipeline.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Talking a little bit more about my solution. It consists of &lt;strong&gt;4 main components&lt;/strong&gt; : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://about.gitlab.com"&gt;GitLab&lt;/a&gt;: It plays dual rule, version control, and CI/CD platform.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://fastlane.tools"&gt;fastlane&lt;/a&gt;: According to the official website, fastlane is an open-source platform aimed at simplifying Android and iOS deployment. fastlane lets you automate every aspect of your development and release workflow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.docker.com"&gt;Docker&lt;/a&gt;: it is a containerization tool that allows a developer to package up an application with all of the parts it needs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://firebase.google.com/docs/app-distribution"&gt;Firebase App Distribution&lt;/a&gt;: Firebase provides this tool which makes distributing your apps to trusted testers painless. By getting your apps onto testers' devices quickly, you can get feedback early and often. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Solution steps? ... let's go 🏃🏻‍♂️
&lt;/h1&gt;
&lt;h4&gt;
  
  
  Step 1: Configure GitLab
&lt;/h4&gt;

&lt;p&gt;GitLab one of the most popular CI/CD platforms. As I mentioned earlier, relying on GitLab for lots of reasons, the most important ,it works as a CI/CD platform and our project versions control.&lt;/p&gt;

&lt;p&gt;a. Create an android project, import the project to GitLab. You can check this question on StackOverflow.com.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;h1&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pTF_nE4a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
            &lt;a href="https://stackoverflow.com/questions/16677931/connecting-to-gitlab-repositories-on-android-studio/46782522#46782522" rel="noopener noreferrer"&gt;
              &lt;span class="title-flare"&gt;answer&lt;/span&gt; re:  Connecting to GitLab repositories on Android Studio
            &lt;/a&gt;
        &lt;/h1&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Oct 17 '17&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/16677931/connecting-to-gitlab-repositories-on-android-studio/46782522#46782522" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5MiFESHx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          93
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Rk_a5QFN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;h1&gt;How to add an Android Studio project to GitLab&lt;/h1&gt;
&lt;p&gt;This answer shows how to do it using the Android Studio GUI.&lt;/p&gt;

&lt;h2&gt;1. Create a new project on &lt;a href="https://gitlab.com" rel="noreferrer"&gt;GitLab&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Chose the &lt;code&gt;+&lt;/code&gt; button on the menu bar. Add a project name and then click "Create project".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.stack.imgur.com/I4oLD.png" rel="noreferrer"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tSJHIzsS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.stack.imgur.com/I4oLD.png" alt="enter image description here"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will give you a…&lt;/p&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    
      &lt;a href="https://stackoverflow.com/questions/16677931/connecting-to-gitlab-repositories-on-android-studio/46782522#46782522" rel="noopener noreferrer"&gt;Open Full Answer&lt;/a&gt;
    
  &lt;/div&gt;
&lt;/div&gt;
 

&lt;p&gt;b. After pushing your project to GitLab, you should configure CI/CD for this project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GkA1iz8l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/tlgmzwba3t9lxkua3uj0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GkA1iz8l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/tlgmzwba3t9lxkua3uj0.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After pressing Setup CI/CD, &lt;strong&gt;gitlab.yml&lt;/strong&gt; created. Throughout this file, we could define the stages of the pipeline. We are going to define the 3 stages of this pipeline as follows: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build&lt;/li&gt;
&lt;li&gt;Test&lt;/li&gt;
&lt;li&gt;Deploy&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Please, keep the file empty and don't worry we will configure our &lt;strong&gt;gitlab.yml&lt;/strong&gt; file later. 😌😌&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 2: Configure fastlane
&lt;/h4&gt;

&lt;p&gt;You can use fastlane as a continuous delivery tool &lt;strong&gt;locally&lt;/strong&gt;. Use any channel(e.g. HockeyApp, Slack, Fabric, etc...) where your deployment will rest.&lt;br&gt;
What are we going to do is we gonna configure fastlane, then we would be able to make fastlane build the project, and place the apk to the channel selected.&lt;/p&gt;

&lt;p&gt;a. Install fastlane in your machine.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Explore &lt;a href="https://docs.fastlane.tools/getting-started/android/setup/"&gt;for Mac and Linux&lt;/a&gt;. (For Mac users, I recommend installation by Homebrew)&lt;/p&gt;

&lt;p&gt;Explore &lt;a href="https://blog.vertica.dk/2019/08/15/automated-android-deployment-with-fastlane-on-windows/"&gt;for Windows&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After installation, check everything is works fine by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;fastlane &lt;span class="nb"&gt;env&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;b. Now, we should start fastlane for our android project. Just open the terminal tab in the android studio. Run the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;fastlane init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;c. Just enter your package name, and you can skip secret JSON file because we are interested in Beta deployments&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--24ql2m8g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ostvowo98cvptvyoqjxw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--24ql2m8g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ostvowo98cvptvyoqjxw.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;d. After that, open your the project mode from project pane on the left-hand side of IntelliJ. You would find &lt;strong&gt;fastlane&lt;/strong&gt; directory created with two files inside.&lt;br&gt;
&lt;strong&gt;Appfile&lt;/strong&gt;: It contains properties and meta-data about your app. Maybe you have multi-flavors. (We aren't interested in this)&lt;br&gt;
&lt;strong&gt;Fastfile&lt;/strong&gt;: it contains configuration what and how to automate your processes i.e build, upload, etc...&lt;br&gt;
&lt;strong&gt;Gemfile&lt;/strong&gt;: it used to define your dependency on fastlane.&lt;/p&gt;

&lt;h5&gt;
  
  
  Remark: Don't forget to force add and push the previously mentioned file.
&lt;/h5&gt;

&lt;p&gt;Now, fastlane has been configured! 😌😌😌&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/5UG0AFAcIlQoZIiOuN/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/5UG0AFAcIlQoZIiOuN/giphy.gif" alt="What's next !"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So have a break 🥐☕️ ... and get ready for the majesty in &lt;a href="https://dev.to/mustafakhaled/devops-understanding-and-applying-ci-cd-pipeline-for-android-developers-part-2-486p"&gt;part 2&lt;/a&gt; 🤓✌️ &lt;/p&gt;

</description>
      <category>gitlab</category>
      <category>firebaseappdistribution</category>
      <category>fastlane</category>
      <category>android</category>
    </item>
  </channel>
</rss>
