# Generate build using build variant in android

**URL:** <https://discuss.bitrise.io/t/generate-build-using-build-variant-in-android/1289>\
**Category:** Question & Answer\
**Tags:** android\
**Created:** [March 28, 2017, 8:58am UTC](https://discuss.bitrise.io/t/generate-build-using-build-variant-in-android/1289 "2017-03-28T08:58:59Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [March 28, 2017, 9:45am UTC](https://discuss.bitrise.io/t/generate-build-using-build-variant-in-android/1289/2 "2017-03-28T09:45:11Z")

</div>

Hi @usmanafzal,

Thanks for asking this here! 🙂

> [@usmanafzal](#):
>
> I need to know how to generate build of particular build variant like

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:

> <https://stackoverflow.com/questions/21307444/gradle-how-to-build-different-flavours-of-different-built-types/21307568#21307568>

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](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) )_

> [@usmanafzal](#):
>
> and I want to generate build for beta when beta flow is selected and staging for staging release

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](http://devcenter.bitrise.io/webhooks/trigger-map/)

A very minimal (not complete, only for demonstration!) example:

```auto
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! 😉

---

_[View the full topic](https://discuss.bitrise.io/t/generate-build-using-build-variant-in-android/1289)._
