Jenkins, Fastlane, Crashlytics, Gradle and Slack — All together


Our team wanted to have a more automated way of releasing builds particularly for the testing team and our client for UAT testing. We previously used Crashlytics Beta and somehow liked it so we wanted to keep it besides adopting Jenkins. How did we achieve that? Fastlane.

Fastlane is set of tools for continuous integration and development. It initially supported iOS automation but later also supported gradle for Android development.

We needed to do two things basically with every build besides sending email notifications to the testers:

  • Send notification on Slack builds channel.
  • Upload the APK built on Jenkins with a certain flavor to  Crashlytics Beta.

First, we need to define a lane with the gradle build variant or flavor we want to release:

lane :quality_control do
gradle(task: "assembleQualityControlFlavorRelease")

We will later call this lane from the sell command in Jenkins.

For slack, we defined our hooks URL for the channel we wanted to send a notification to. You get the URL here.

default_platform :android
platform :android do
before_all do

And to actually send the notification on a specific channel:

slack(channel: "#android-builds",
message: "QC build  has been uploaded successfully",
default_payloads: []

You need to have a Crashlytics api token and build secret. Also, you need to know the path to where Jenkins uploads the build after a job is done. You then put down the groups that you want to notify when a new build is ready (groups should be defined from Crashytics Beta, you just reference them here). And finally, add some build notes:

api_token: "API TOKEN",
build_secret: "BUILD SECRET",
groups: "android-developers, de-testing",
notes: "QC environment",

The final step is to go to the Build section section in the project configuration on Jenkins and actually call the lane via this Shell command:

chmod +x gradlew
#!/bin/bash -l
echo q6jwsn6dytu | sudo -S gem update fastlane
fastlane quality_control

Now every time a new build is created, this line will trigger the whole process of uploading to Crashlytics and notifying slack channel.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s