I need to know how to generate build of particular build variant like I have 3 build variants
- beta
- staging
- production
and I want to generate build for beta when beta flow is selected and staging for staging release can anyone help me out?
I need to know how to generate build of particular build variant like I have 3 build variants
Hi @usmanafzal,
Thanks for asking this here!
You can run / specify the flavor specific Gradle Task, every flavor should have e.g. an assembleX
task which can be run as a gradle task:
You can set the Gradle task as the Gradle task to run option of the Gradle Runner step.
You can get the full list of tasks you can run with gradle on your project with: gradle tasks
( source & more info: http://devcenter.bitrise.io/android/android-tips-and-tricks/#what-are-gradle-tasks-and-how-can-i-get-the-list-of-available-tasks-in-my-project )
Just create corresponding workflows, or use Workflow Environment Variables for beta, staging, production, … and specify the Triggers when to run which workflow: Using the Trigger Map to trigger builds - Bitrise Docs
A very minimal (not complete, only for demonstration!) example:
format_version: 1.3.1
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
trigger_map:
- push_branch: master
workflow: release
- push_branch: '*'
workflow: beta
- pull_request_source_branch: '*'
workflow: beta
workflows:
beta:
steps:
- gradle-runner@1.5.4:
inputs:
- gradle_task: assembleOne
release:
steps:
- gradle-runner@1.5.4:
inputs:
- gradle_task: assembleTwo
This configuration will select the release
workflow for pushes on the master
branch, and for pushes on any other branch and for Pull Requests it’ll select the beta
workflow.
The beta workflow’s gradle runner step will run the assembleOne
gradle task, while the release
workflow’s gradle runner will run the assembleTwo
task.
If you have any questions just let us know!
Happy Building!
Hi, @viktorbenei
How can I achieve this using Android Build
step? It provides Variant
input, but I can succeed with only single variant. It wasn’t work splitting with \n
, space
. According to this, I think it should work with \n
Here is my build log.
Hy @Hanchul_Kim!
I would suggest trying with two steps for the two flavours, or try the separation by single spaces.
Hi, @fehersanyi-bitrise
If so… there would be no other options, except splitting into two steps. Separation by single space doesn’t work.
Hi @Hanchul_Kim!
Maybe I’m missing something but I’m wondering, do you lose anything by including this in two steps? It should be the same amount of build time and easier to see through since they are separated.
Hi, @bitce
Not really, but I just expected Build Variants
not Build Variant
in a single step. I just felt it would be better to provide multiple variants in a single step. Although it’s not a common situation, 5 variants needs 5 steps.
It won’t work. As we can see in source code only single variant or empty input is accepted for now. https://github.com/bitrise-steplib/bitrise-step-android-build/blob/master/main.go#L102
BTW the recommended separator is |
(pipe character): https://github.com/bitrise-io/bitrise/blob/master/_docs/step-development-guideline.md#inputs-which-can-accept-a-list-of-values
Indeed @fehersanyi-bitrise is right @Hanchul_Kim - the Android Build step only supports a single variant, but you can of course add multiple Android Builds steps.
The “old school” Gradle Runner step accepts multiple gradle tasks, so that can also be an option, but based on our past experience newer steps created by us usually focus on doing one thing at a time, similar to how most people use the related GUI options during development, this way describing what you’d do if you’d perform these manually.