Adding environment variables with gradle: yes

My v2.3.0 build broke on F-Droid and I have been working to get it back up running. The issue I am running into is that I need a couple of environment variables to be present during app build. I can't put these in a file since I am running a React Native app and it's the only way to pass in the variable. My current metadata file can be found here: https://gitlab.com/leinelissen/f-droid-data/-/blob/fix-fintunes-v2.3.0/metadata/nl.moeilijkedingen.jellyfinaudioplayer.yml.

I have tried the following approaches:

  • putting export BLAH=blah in either init or prebuild. Doesn't work as those commands are run in a single bash -c and the environment variables will disappear as soon as the init or prebuild section completes.
  • inserting the environment variables in .bashrc. Doesn't work as whatever happens when gradle: yes isn't executed in a new shell.
  • custom build step without gradle: yes including export BLAH=blah. Doesn't work as the build step fails when Updating main project happens, eventually breaking on Invalid or unsupported command "update lib-project -p ." . See https://gitlab.com/leinelissen/f-droid-data/-/jobs/6339095656.
  • custom build step with gradle: yes including export BLAH=blah. assembleRelease executes twice, and fails the second time because the environment variables are not available: See https://gitlab.com/leinelissen/f-droid-data/-/jobs/6339831895.

I don't fully grok what happens when gradle: yes is set, and how I can influence it to pick up environment variables from e.g. prebuild. I see a lot of projects directly manipulating gradle files, but my current setup can only support environment variables, so this is not currently an option. Hope any of you can help out!