Note: the start point discover of question “How automate the process of upload build” began from one of the evenings when, as usual, I write off hours for our corporate time tracker and I noticed that i had a situation, when I upload 3 build per one day and I spent 3.5 hour for it, I was surprised of it, because all of us know steps of upload build on testflight e.g. (useless spending time near computer). And then a meet with fastlane, then with Jenkins and then set up one of the corporate mac os machine for CI / CD server. In this article I’ll explain how I did it, what issues i meted and resolved. Have fun �




Open terminal and put on the command:

sudo gem install fastlane -NV


Open project folder in terminal and execute the command:

fastlane init
Terminal ask your goal, just pick “For beta in testflight” (this option will generate the main commands for your goals but they might be not enough for use and that’s why it’s no matter what you pick because we will write script by yourself).
After that in git package will be created a new package named “fastlane” into this package will be several files:

Fastfile – data about your account.
AppFile – file for script code.

Credentials management

Fastlane give us perfect possibilities for manage of certs and provision profiles by call several commands for different methods (appstore, development, adhoc, enterprise). Methods:


The main goals of this – management of credationals (certs, profiles). You can setup this once for project and then avoid a problem with search, update, download certificates and provisional profiles.
The main idea of match it’s remote private repository with your credentials, which will be care by several commands from terminal.
Why I don’t recommend this method? Because it’s most useful when you have only one project per account, due to manage of multiply apps is harden for this method.


Open your folder with source code in terminal and put on this command:
fastlane match init
You’ll be asking of URL for your private credential repository, just copy-paste path to repo in terminal.
After that in fastlane package will be created a new file named “Matchfile” with data about your repo and account.


Open package with source code in terminal and execute the commands:
fastlane match appstore

fastlane match development

In process you will be asked by terminal for create a passphrase for certificates, you should come up with something and keep it because in the future you might need it. Execution of this command you will create a 2 certificates (development, distribution)
and 2 provision profiles (development, distribution).
You can check it in developer portal.
After creation all of them will be automatically download and install on your machine. In next time for download and install certs and profiles you should execute one command on your source code package via terminal:
fastlane match method


This method care of our certificates for different methods. Call
fastlane run cert method
and script will check if you already have a certificate, then download existed or create new, and then auto install on your machine. More details.


This method care of our provision profiles for different methods. Call
fastlane run sigh method
and script will check if you already have a provision profile, then download existed or create new, and then auto install on your machine. More details.
*All of methods support – readonly option for avoiding regeneration creds. It useful when you will write script for your CI machine or for new members in your team.
Also, after call one of commands in your source code package you can see creds which were loaded.
The next step that required to do – it’s an introduction generated provision profiles into your project, if you will skip this step you might have a problem with build and archive your project through fastlane.
One of error that might be due to avoid this step:
Open xCode disable “Automatically manage signing” and replace provision profiles for “Debug” and “Release” that we generated before (generated profiles include a “match” substring).
I recommend you use cert + sigh because sigh working well with existed cert, you will haven’t problem to subscribe new provision profile by existed cert instead of match which follow only creation new certificate and after that generate profiles, this produce a collision, when you will regenerate new certs for new project and all of your old provision profiles will be invalidate (if you already rich maximum of certs and should remove and create new).

Scripts example

In this doc all of command which might be usefull for make script for your goals. The scripts below show you how we can avoid of pain, install all of credentials or upload new build to app store connect.
First script only for take care of creds:
Second script does several actions:
  1. update cocoapods
  2. load the cert and provision profiles, install/create them if need
  3. increment of build number by increment the last build number from
  4. build the project and make archive (all of subscription will be
  5. generated archive will be upload to testflight
  6. open for internal testers
“lane: testflight_beta” – it’s first line of your script that means “it’s beginning of my script which named testflight_beta”.
You can execute this script by command line, open package with your source code in command line tools and execute a command:
fastlane run testflight_beta
And our script will start of execution. But we a lazy and would to automate all of process, that’s why go next 🙂



This is the one who will do our works 🙂


brew install jenkins-lts


brew services start jenkins-lts
In this doc all of command which might be usefull for make script for your goals. The scripts below show you how we can avoid of pain, install all of credentials or upload new build to app store connect. Open browser and go to localhost:8080, and you will see the start page of registration. I wouldn’t copy-past tutorial “How to install Jenkins and start of work” because I use the source tutorial from jenkins web-site and recommend you do the same.
After registration, open dashboard and create new item (see picture below).
Enter name and choose “Freestyle project”
Then we should fill several sections for configurate our job.

Source Code Management

Enter source code repository URL.

Then enter “Branch specifier” which will be triggered for new build (default value is a master).

If you use private repository, you should to add a credentials for sign in. Just enter your credential on this form (Id and Description is optional, for more details click on question mark ).
Then pick your account on this account list.

Build triggers

Pick “Build when a change is pushed to BitBucket”.

Build environment

On this section we need pick two set up


Use secret text (s) or file (s):
Add variables by this rule: “Add”->”Secret text” put name of var in field “Variable” choose “specific credential” and press “Add” (before check that your credentials not exist otherwise pick from list). If you pressed the “Add” in open window pick “Kind”->”Secret text” and then enter “Secret”- your value of var, “ID”- name for pick list of this var (free name). Enter the next variables:

Open project folder on your mac and enter command:

fastlane spaceauth -u

After execute a command, terminal ask you to copy generated cookie (as string) in your clipboard, copy string and put in as value for variable in Jenkins.

If you have enabled 2FA authentication you should set still a two variables.

Go to manage and generate the password, enter the reasons and generate (after
generate keep the string because have no possibility to see it again)

After that, put on generated string as secret for variable.

Go to and copy the one of the trusted phone numbers (this field sensitive of phone mask and that’s why copy the phone such on the web page)

After that, put on phone as a secret for variable. Your section will seem something like that.


Inject environment variables to the build process.
Set the “Property content” just put on this:



Add “build step” by pick “execute shell” from the list. And put the command which will be start of actions what you want (it’s such a terminal command which will be begin of your fastlane script).
Click save and go to dashboard, there will appear a new job
Pick the project and then click “Build now” on left side menu
� � � We manual launched our job process. In build history should appear a new build. It remains automatically launch the build process by trigger bitbucket changes. Go next 🙂

Ngrok Service

In two sentences, this service will be working on the mac os machine (CI) and make our localhost visible for network. It is giving possibilities for Jenkins to listen a changes in bitbucket repository and call the trigger for make new builds. For correct work ngrok service should work on the same port such a Jenkins. As before i wouldn’t to copy-paste tutorial “How install grok?” that’s why I recommend you use simple and useful tutorial from creators.
For start working open terminal and call the command:
ngrok http port
*port – default value 8080.


Go to your bitbucket “project dashboard” -> “repository settings” and pick “web hooks” ->”add hook” you will see:
The next back to bitbucket window, put on the url field and click button save.
That’s all, now you can push something in your master branch and check that everything working well. Every time when master branch will be change on Jenkins project dashboard you will new builds.

That’s all

Note: the first time I meted a lot of problems due-to I haven’t contacts who can share experience with me, I use tutorials which time to time answered on my questions and also official documentation of fastlane. Nevertheless on my opinion all of devs who already meeting with process of uploading builds, tests, and before didn’t noticed services like that, should at least once try to use this chain, and felt benefits of this power tool.

Test Driven Development as a methodology: Client vs. Developer perspective


What is a CTA button and why it’s so important for website? ⚡️