0

I have a CodePush app that has three deployments: testing, staging and production.

I have different app builds that align with these:

  • A build that does out to testers (testing)
  • A build that goes out to a group of preview users (staging)
  • A production build (production).

How does CodePush know what deployment it should be sending to a build?

And how do I set up my app to make sure the right build (e.g. staging version of app) is getting the right deployment (e.g. staging deployment in CodePush)?

David Ferenczy Rogožan
  • 23,966
  • 9
  • 79
  • 68
onblur
  • 365
  • 1
  • 5
  • 16

2 Answers2

1

The CodePush server knows which deployment you want to query for updates against based on the deployment key which is configured in the config.xml file or is passed to the call to sync (with the later taking precedence). If you want to generate three separate builds for QA/staging/production, then you simply need to make sure you update the deployment key that is set in your config.xml file before running cordova build to generate the APK or IPA file.

Unfortunately, Cordova doesn't really have a standard way of defining multiple environments, which would allow you to add your per-environment keys to the config.xml and have the right one be selected when doing an environment-specific build.

Depending on how your app is structured, you could also skip the config.xml file completely, and just pass the deployment key directly to the call to sync(). Then, you just need to make sure your app defines all the neccesary keys in a config somehow and loads the correct one for each build. You can take a look at this starter project for an idea of how this could be generally done.

Jonathan Carter
  • 1,029
  • 1
  • 9
  • 17
  • Thanks Jonathan. I'm using checkForUpdate() instead of sync() but I see from the docs that both will accept an arg for deployment key. The background to this question is working out how to get the promotion of releases working. Since our builds know what kind they are (test, staging, or production) it will be pretty straight forward for me to pass the appropriate deployment key with checkForUpdate() – onblur Feb 28 '16 at 01:24
  • Awesome! I would love to chat more about your per-environment build setup. Email me at joncart@microsoft.com if you'd be up for syncing on it. It would be really insightful for our team to see how you're doing it. Thanks! – Jonathan Carter Feb 28 '16 at 03:01
  • @onblur will you add an answer to this question about how to set multiple environments in cordova, please? – Halt Jul 18 '18 at 08:12
0

I have configured CodePush for my dev, test and prod environments. But my application is a react-native one. I think the same will works for Cordova as well.

The important point is CodePush identify particular app by it's CodePushDeploymentKey. First you should create 3 channels on AppCenter for dev, test and prod. Then setup CodePush on those 3 environments and Get relevant CodePushDeploymentKeys.

Then you have to add those 3 keys for 3 different targets on your app. For iOS you can create 3 different targets on Xcode with 3 different plist files and add those different CodePush keys in relevant plist files.

For android you can create 3 different Product Flavors for dev, test and prod and then add DeploymentKeys on each flavor.

In this article I have explained everything step by step with all the screenshots and links.