continuous delivery continuous integration fastlane iOS jenkins swift Technology Tutorial

Continuous Integration and Continuous Delivery with Jenkins and Fastlane

Continuous Integration and Continuous Delivery with Jenkins and Fastlane

Testing has been a vital a part of most medium-to-large tasks, therefore, it is vital that each code change to our most important branches triggers a full execution of check suite, in order to make sure that the change we made doesn’t break another check instances. This complete course of is what we name Continuous Integration (CI). It’s to validate the correctness of code modifications and to shortly determine integration errors.

After receiving a inexperienced mild from CI, the subsequent step is to make sure supply of the brand new software program that consists of latest options and/or bug fixes. That is what we name Continuous Delivery. Because the check suite was already taken care of by CI, right here we run scripts to signal certificates (in Xcode/iOS contexts), and carry out archives with third-party device like FastLane to set off a deployable software program that may be despatched to customers’ emails for fast testing.

What’s Jenkins?

Jenkins offers us seamless methods to arrange a CI/CD setting for nearly any mixture of code languages and supply code repositories utilizing pipelines. It’s an open supply automation server which can be utilized to automate duties associated to constructing, testing, and delivering or deploying software program. Additionally it is an important software that assist the DevOps groups, which is getting extra fashionable these days because of the growing quantity of tasks we handle at a given interval, to make sure their top quality deliverables. Jenkins has plugins that integrates with third-party source-controllers like Github and BitBucket.

What’s Fastlane?

FastLane is a Ruby-written CD device for releasing cellular apps (iOS/Android), eliminating tedious duties for you. Because of its earlier improvement for the iOS ecosystem, we will see extra functionalities made out there to iOS than Android.


To undergo this tutorial, I assume you will have outfitted your self with the next information and instruments:

  1. Some primary information in constructing iOS tasks.
  2. Some Unit-Testing information with Fast & Nimble in Swift.
  3. Some Net Internet hosting information.
  4. A mac machine to comply with this tutorial.
  5. A developer account to generate certificates.
  6. Endurance

Establishing this complete course of is time-consuming and tedious. It was via lots of trials and errors that I might piece the whole lot collectively to return out with this tutorial. On the time of writing, there may be updates coming in and the content material is perhaps out of date. Do examine the model upgrades this arises and deal with accordingly. Don’t hesitate to drop me a remark so I might credit score you and replace this tutorial as nicely to profit the remaining! Thanks 🙂

What is going to you study?

You’ll study rather a lot about CD and CI by going via this tutorial together with:

  1. How one can arrange Jenkins 2.121.three (Java eight).
  2. The right way to arrange Fastlane.
  3. The way to handle your CI with Jenkins + Github.
  4. Find out how to handle your CD with Jenkins + Github + Fastlane.
  5. Tips on how to arrange CI/CD in your challenge.
  6. How you can use Webhook Relay to hook Github with Jenkins.

Arrange Jenkins

Let’s begin off by downloading Jenkins on the machine you want to host CI/CD. I personally favor the Lengthy-term Help (LTS) as a starter. As it’s written absolutely in Java, you’ll need the suitable model of Java to launch the .warfare file afterward.

As soon as the obtain is accomplished, unpack the package deal and set up its contents. It should routinely set up Jenkins into Purposes folder. As Jenkins 2.121.three is written in Java eight, we’ll want the identical model to execute the struggle file. Do a fast verify of the model at present in your path by operating:

For me, I’ve:

Therefore, I might want to change to the supported model. You can obtain it right here.

After putting in of Java eight JDK, run:

Please guarantee you’ve got output just like the next:

Now let’s set our default java model to 1.eight to run our jenkins:

Run Jenkins struggle file:

Viola! You now have your jenkins operating on localhost:8080!

As seen on the primary display, simply copy the url and run vi /Customers/[computername]/.jenkins/secrets and techniques/initialAdminPassword in terminal to retrieve your password (or you can get it from console log in terminal). Comply with the wizard and:

  1. Set up recommended plugins
  2. Create a Consumer Admin Account
  3. Set url (we will use http://localhost:8080/ for this tutorial)

You need to be greeted with Jenkins Dashboard and prepared to start out creating CI/CD jobs for our challenge!

Set up Jenkins Plugins (Github & Xcode)

To allow Jenkins obtain a notification from Github and run a job, it is going to require a plugin to be put in in our Jenkins server.

  • Go to your plugins supervisor
  • Discover and set up GitHub plugin
  • As soon as put in, head over to Configure System and search for Github Server so as to add Default Github Servers. We dont have so as to add credentials right here since we might be utilizing public repo.
  • Additionally replace your Xcode Builder settings and guarantee you could have the suitable plugins.
  • Set up Xcode plugin.

Create Jenkins Job

Now, return to our Jenkins Major Dashboard and create 2 new jobs.

  1. TruthOrDare-CI (Freestyle Undertaking)
  2. TruthOrDare-CD (Freestyle Challenge)

Let’s simply configure our TruthOrDare-CI first by heading over to Supply Code Administration and allow Git. Copy your public github repo url in. It can look one thing like[user]/[project].git

We’ll change our Department Specifier right here from */grasp to */develop.

  1. We’ll run CI for each change made to develop department.
  2. We’ll run CD for all CI change(s) made to grasp department.

If we made a number of code modifications to develop department, we don’t need to generate a construct for every code change. More often than not a function consists of a number of code modifications (besides bug fixes). As soon as all these code modifications have their CI handed, we’ll merge them into grasp the place it can run CD and push a construct to your said emails.

Subsequent we’ll toggle on GitHub hook set off for GITScm polling. That is the primary change that permits Jenkins to answer webhook the place it identifies which repo is modified and then run jobs.

Configure your Webhook

As talked about, we’ll now arrange our webhook by following this set up steps.

Upon getting CLI downloaded, use it:

and then begin forwarding your webhook to Jenkins:

When you see the next message, this implies your webhook relay succeeded!

Woohoo! You deserve a pat in your again for coming this far!
Paste this url in a notepad or one thing, you’ll need it quickly.

Now add this webhook into Jenkins.

By now you must have 2 terminals opened:

  1. Operating Jenkins
  2. Operating Webhook Relay

Obtain Xcode venture and Push to Github

For simplicity, I can be offering a pattern challenge right here name Fact or Dare. I encourage you to create a brand new public repository your self and push this code to a repo of your option to comply with this tutorial intently. This undertaking integrates with Fast & Nimble utilizing Carthage to run unit exams as a part of CI’s course of to make sure check suite all the time passes earlier than a merge might be executed. So go forward and push this to Github.

As we’re utilizing Carthage, we might want to add carthage replace command in Jenkins to construct the folder required in Jenkins. So go forward and add this command as one other construct step in each Jenkins jobs.

Do keep in mind to arrange your personal App ID in your Apple Developer Portal. Generate the certificates so our Jenkins jobs can construct efficiently.

Use Webhook in Github

Now seize the webhook relay url you generated simply now, which seems one thing like, and paste it in your repo’s webhook part.

That’s it! The agent is operating and forwarding requests.

Arrange Fastlane

Now let’s arrange Fastlane by operating:

Then, head to TruthOrDare‘s venture folder and run:

🚀🚀🚀 Your Fastlane is initialised! 🚀🚀🚀

It’s time to up the velocity right here since our Fastlane is now activated! Let’s select four 🛠 Guide Setup. After this you need to have generated:

  1. AppFile
  2. FastFile

Open Fastfile in your favorite TextEditor and paste this code in:

You will have to fill in three gadgets:

  1. E mail to obtain construct from Crashlytics.
  2. App API Token from right here.
  3. App’s Organisation’s Secret from the identical dashboard.

Right here, we have now created 2 lanes:

  1. fastlane CI to run exams on our Jenkins.
  2. fastlane CD to construct and push construct to Crashlytics.

So let’s return to Jenkins and embrace this command as our subsequent construct step.

Phew, take a deep breath

Let’s recap what we simply did:

  1. We arrange our CI/CD Jenkins on machine or localhost.
  2. We did a Webhook Relay/Forwarding to a public url.
  3. We created and pushed our Xcode Venture to a public Github repo.
  4. We arrange the repo’s webhook utilizing the general public url.
  5. We arrange fastlane on our repo.

Prepared? Get Set … Go!

Congratulations! You could have accomplished establishing the automation course of! In case you encounter some points because the automation runs, don’t be dismayed, drop a remark under and we will clear up it collectively. The outcomes could also be totally different from machine to machine, however the idea is that this!

So let’s checkout from grasp department to our develop department and make a change to the code base. Substitute our truths array with this:

  1. Do an add: git add TruthOrDare/ViewModel.swift.
  2. Do a commit: git commit -m “Add Comment Truths”
  3. Do a push: ‘git push

Go to Jenkins now. After a number of seconds, you need to see your CI job operating. Check out the console log and see if all the things goes nicely.

OH NO! The standing turns pink as a result of our check case failed. The check case outcomes level us to the truth that one of many fact is being edited! You don’t want unauthorised code modifications!

That is one great thing about CI, the place it all the time ensures the correctness of the app particularly when the app grows, it’s straightforward to change different codes that you’ve written many years in the past. A break within the CI or operating check case regionally will provide you with a touch.

Attempt placing again the code and push the code once more.

You need to see the Standing turned Blue this time!

Let’s add yet one more fact and yet one more dare so we might run our CD.

  1. What’s your deepest darkest worry? (Fact)
  2. Serenade the individual in your proper. (Dare)

Don’t overlook to make modifications to your check case! Now do a:

  1. git add .
  2. git commit -m “Add new Truth and Dare!”
  3. git push

Let the CI undergo.

Operating our CD

As soon as CI succeeded, lets run our CD! Keep in mind that we’re observing grasp department for CD? Go forward and

  1. git checkout grasp
  2. git merge develop
  3. git push

As our grasp department nonetheless holds the codebase with solely 5 Truths & Dares, we have to merge in modifications we comprised of develop. As soon as modifications is utilized, CD will begin operating and viola! You’ll obtain the construct at your e mail!

You may have to run it twice in case your gadget just isn’t registered with Crashlytics. You possibly can set off the construct manually by clicking Construct Now.


So what have we achieved?

  • We learnt in concept how CI/CD works from code decide to launch of a construct.
  • We learnt the right way to Setup Jenkins.
  • We learnt how you can Setup Webhook.
  • We learnt the way to Setup Fastlane & Crashlytics.
  • We learnt the way to Combine and Automate your complete course of.

All of us deserve a pat on our again, one for finishing the write up for this tutorial, and one so that you can comply with via this prolonged course of to get your CI/CD up and operating!

Wrapping Up

In case you have any questions concerning the tutorial, please depart your feedback under and let me know.

If you need me to put in writing follow-up tutorials with extra superior CI/CD methods like caching Carthage or integrating with Pull Requests, don’t hestitate to drop me a remark!

(perform(d, s, id)
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); = id;
js.src = ‘’;
fjs.parentNode.insertBefore(js, fjs);
(doc, ‘script’, ‘facebook-jssdk’));

About the author