Ionic Pro Deploy builds not injecting environment variables or deploying


#1

I’ve hit an impass with Ionic Pro’s build process. I’ve followed the official doc, I think, to the letter:

  1. The build environment is using @ionic/app-scripts@3.2.0
  2. The src/declarations.d.ts file has been created as per the official doc
  3. In the app there is a switch statement starting switch (process.env.CI_GIT_REF) {
  4. Deploy is successfully building via a git repository branch on GitHub and automatically assigning it to a ‘Demo’ channel.
  5. I have run cordova plugin add cordova-plugin-ionic --save --variable APP_ID="XXXXXXXX" --variable CHANNEL_NAME="Demo" --variable UPDATE_METHOD="background" (substituting the correct APP_ID)

But when I close the app on an iOS device and open it up again (haven’t tried Android yet), process.env.CI_GIT_REF is always undefined. I’d expect to see the branch name that Ionic Pro’s Deploy build injects. If I JSON.stringify() the process object on the iOS device I get the following:

{
  "title": "browser",
  "browser": true,
  "env": {},
  "argv": [],
  "version": "",
  "versions": {}
}

The app never updates to a later build on the channel. Even though Ionic Pro’s Monitoring is working! The app shows no error messages to suggest anything is wrong.

Have I missed something about how Ionic Pro’s Deploy build injects the environment variables? Is there typically a long delay before a build will be picked up after an app restart on the device? I’ve tried waiting for several hours.


#2

I think I’ve misunderstood the environment variables. I suspect they’re only available during the webpack build, i.e. not injected into the source code and therefore available when the app is running, like I’d originally thought. But I still can’t get Deploy working


#3

Since posting this, I have used Ionic Pro’s support system to resolve this issue. They are helpfully investigating the Deploy issue.