Embedded feature flags

3 minute read

CloudBees Feature Management enables you to pack custom deployment rules and configurations at build time using embedded feature flags. With embedded flags, you can control elements which are required at startup without introducing any lag time in fetching data from the network.

Embedded flags allow you to set custom default configurations, such as releasing a feature only for beta users in a specific country. In contrast, default values are served when there are no other configurations available. For more information, refer to Setting the flag default values.

You can configure embedded flags for Android, Java Server, iOS, and JavaScript SDKs.

Android

The Gradle plugin can find all necessary information from Android sources automatically. Refer to ROX Configuration Gradle Plugin for Android for more information about installation.

By default, the plugin looks for the ROX app key in AndroidManifest.xml. You can change this using the resValue config in build.gradle:

defaultConfig { resValue "string", "YOUR_APP_KEY", "<YOUR_APP_KEY>" } buildTypes { debug { resValue "string", "YOUR_APP_KEY", "<DEBUG_APP_KEY>" } release { resValue "string", "YOUR_APP_KEY", "<RELEASE_APP_KEY>" } }

You can also override default values by specifying them in Gradle’s rox extension. Config property names and default values are displayed below:

rox { resKey "YOUR_APP_KEY" // resValue key to extract appKey xmlKey "rox.apiKey" // android manifest key to extract appKey host "https://x-api.rollout.io" // host to get configuration from platform "Android" // platform to send with request fieldName "ROX_EMBEDDED_CONFIGURATION" // field name in BuildConfig.class which stores the configuration groupId "io.rollout.rox" // groupId to identify the SDK version artifactId "rox-android" // artifactId to identify the artifact name of the sdk buildTypes "release,debug" // list of build types, separated by ',', to apply to plugin. Empty string "" is the default (all build types). apiVersion "1.8" // ROX API version }

Java Server

The Java Server SDK has both Gradle and Maven plugins for the two popular build automation tools.

Java Server: Gradle plugin

To use Java Server with Gradle, install the Gradle plugin. Refer to ROX Configuration Gradle Plugin for Java Server for more information.

After installing the Gradle plugin, specify your app key in build.gradle:

rox { appKey "<YOUR_APP_KEY>" //appKey value }

The property names and default values for the Gradle plugin are displayed below:

rox { appKey "YOUR_APP_KEY" // appKey value host "https://x-api.rollout.io" // host to get configuration from platform "Java" // platform to send with request fileName ".rox-embedded-configuration.json" // name of the embedded configuration file located in the classpath groupId "io.rollout.rox" // groupId to identify the SDK version apiVersion "1.8" // ROX API version }

Java Server: Maven plugin

To use Java Server with Maven, add both rox-java-server and rox-configuration-maven-plugin dependencies to your pom.xml:

<project> ... <dependencies> <dependency> <groupId>io.rollout.rox</groupId> <artifactId>rox-java-server</artifactId> <version>5.0.1</version> </dependency> </dependencies> ... <build> <plugins> <plugin> <groupId>io.rollout.rox</groupId> <artifactId>rox-configuration-maven-plugin</artifactId> <version>1.0.0</version> <configuration> <key>YOUR_APP_KEY</key> </configuration> <executions> <execution> <phase>generate-resources</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>

The property names and default values for the Maven plugin are displayed below:

rox { key "YOUR_APP_KEY" // application key host "https://x-api.rollout.io" // host to get configuration from platform "Java" // platform to send with request fileName ".rox-embedded-configuration.json" // name of the embedded configuration file located in the classpath groupId "io.rollout.rox" // groupId to identify the SDK version apiVersion "1.8" // ROX API version }

iOS

Add a new Run Script phase to your target, using the following:

“${SRCROOT}“/Pods/ROXCore/lib/store_rox_configuration.sh -k “<your_app_key>”

JavaScript

Install the plugin with npm install --save-dev rox-embedded-webpack.

Add the plugin to your Webpack config, as displayed below:

const ROXEmbeddedPlugin = require('rox-embedded-webpack-plugin'); module.exports = { entry: //..., output: //..., plugins: [ new ROXEmbeddedPlugin(options) ] }

The object options has the following keys:

{ app: <YOUR APP KEY>, platform: <YOUR_PLATFORM_OF_CHOICE>, // you can use 'Browser' here output: <ABS_TEMPORARY_OUTPUT_DIR> // optional }