📜 ⬆️ ⬇️

Local automation of builds (Crashlytics + Slack + FastLane)

Build automation (Crashlytics + Slack + FastLane).

Before (Black and white picture, a sullen developer sits at the table)

1. Increases code version in build.gradle
2. Build build
3. Build crashlytics build
4. Writes to the sluck that flooded the new build
')
Now (bright picture, funny guy):

console: fastlane new_build

Now seriously. In our business, you need to automate everything, and in this article I will explain how to automate the release of builds using fastlane.

Fastlane is a product from the fabric that helps automate the creation of builds for android, ios and mac. I work on a mac and will talk about the installation on it.

A few preparatory steps:

  1. You will need to install xcode (the necessary libraries are installed with it)
  2. Install the fastlane itself. Click here and choose what we want to connect and download the archive
  3. Inside you will find the installer / install file. Install it (Most likely you will need to enable the option to install in the security settings not from the side)
  4. And the last boring step, in the console we write:
    cd /path_your_project
    fastlane init
    this will create a fastlane folder in your project.

And when all the preparatory steps are completed, the fun begins. In the fastlane folder there is a file Fastfile (The guys did not bother with the names), this is a ruby ​​script.

Immediately you need to understand the two basic concepts of lane and action .

Lane is a set of action that will be executed. There may be several of them; they can differ from each other in, for example, the launched gradle task. And we will run Lane directly.

Action is the action that fastlane can do. Here is a set of available Action

And now a bit of code:

 #  lane - test (    : fastlane test) lane :test do #    gradle(task: "assembleDevDebug") #    crashlytics crashlytics( api_token: "api_token", build_secret: "build_secret", emails: "name@gmail.com, ivan@gmail.com", #       note   notes_path:"/Users/Android/notes.txt" ) slack( #    web hook,        slack_url: "https://hooks.slack.com/services/dddd/ddddd/ddddd", icon_url: "https://icon.png", username: "Android", default_payloads: [:test_result,:last_git_commit_message], payload: {"Build Date" => Time.new.to_s,}, message: message ) end 

All customization options for action can be viewed at the link.

What we have done quite well already. We can build a project in one line to load it into crashlytics and write a message about it in slack. By the way, this is how it looks like:



On real projects, there is a need to build different assemblies for different purposes, for example: on a live server for customers and on a test server for testers.

This can be done through the product flavor in gradle. If this article will be interesting to readers in the next, I will tell you how to make it possible to convene different assemblies for different needs, auto increment the code version in the necessary assemblies and write about it in slack.

Source: https://habr.com/ru/post/343714/


All Articles