versionCode/buildNumber as builtin EAS environment variable

In my CI (on GitLab) I use BUILD_CODE=44312 eas build

In my app.config.js I have a call to process.env.BUILD_CODE in an attempt to set the versionCode/buildNumber. Only after a few tries I learned that external CI variables are not accessible inside EAS build servers. However, the UI of EAS builds shows my version code:

That means that app.config.ts is also parsed with access to my GitLab CI variables.

There are a few builtin EAS environment variables already (listed here).

Is it therefore possible for a sort of EAS_BUILD_CODE to be introduced?

You may be able to do something with the Remote Version Management feature. This will allow you to set and store a build code on the Expo servers that can be read during your build. I think in your case, assuming you already have a source incrementing your build numbers, you would set autoIncrement to false and use the eas build:version:set command to set it just prior.

Additionally, you could also set a custom environment variable in eas.json. Your CI process could edit that file with the new build code just prior to submitting the build. Even though the value isn’t checked in, the updated file would still be uploaded to EAS Build. This would work quite similarly to the “local version management” option described in the link above (just storing it in eas.json instead of app.json).

1 Like

Thanks, I think in this case I will go with the second suggestion.

What I now did (since eas build:version:set seems to have to be run interactively) was using eas:secret:create to set a env var with the build id. But editing eas.json would allow for concurrent builds so that is nicer. Thanks!

1 Like