-
Notifications
You must be signed in to change notification settings - Fork 102
Description
After upgrading to Instabug 16.0.0, our Android release build started to fail with:
> Task :instabug-reactnative:uploadSourcemapsStaging FAILED
✅ Resolved sourcemap file path: /Users/administrator/actions-runner/_work/appName/appName/android/app/build/generated/sourcemaps/react/stagingRelease/index.android.bundle.map
Script failed with exit code 1
Standard Error:
Standard Output:
Couldn't find Instabug's app token
Failed to upload source map file.
Reason: Could not get unknown property 'tokenShellFile' for task ':instabug-reactnative:uploadSourcemapsStaging' of type org.gradle.api.DefaultTask.
Only the debug build works.
As shown in the error, it fails during sourcemap upload, because it doesn't find the token. This used to work fine before.
To provide the Instabug token on CI, we've ben using the env variable strategy (INSTABUG_APP_TOKEN
), like described in the docs.
We do that because in our app we don't hardcode the token on the Instabug.init
statement, since we need to swap tokens based on environment/stage.
I noticed that in 16.0.0 this was added:
Instabug-React-Native/android/sourcemaps.gradle
Lines 50 to 57 in d67d2a2
def tokenJsFile = new File(instabugDir, 'scripts/find-token.js') | |
def inferredToken = executeNodeScript(tokenJsFile, jsProjectDir) | |
if (!inferredToken) { | |
throw new GradleException("❌ Unable to infer Instabug token from script: ${tokenShellFile.absolutePath}") | |
} | |
def appToken = resolveVar('App Token', 'INSTABUG_APP_TOKEN', inferredToken) |
It fails if the token can't be inferred from files and it never proceeds to look for the env variable.
Here is how it looked like in 15.0.3:
Instabug-React-Native/android/sourcemaps.gradle
Lines 47 to 49 in b67c58d
def tokenShellFile = new File(instabugDir, 'scripts/find-token.sh') | |
def inferredToken = executeShellScript(tokenShellFile, jsProjectDir) | |
def appToken = resolveVar('App Token', 'INSTABUG_APP_TOKEN', inferredToken) |
As you can see, it previously didn't fail early when the token couldn't be inferred from files only.
And also noticed you switched from the previous find-token.sh to a new and more strict (will look up in less places) find-token.js.
It looks like these last changes are making the build fail on Android if you only rely on the env variable, making the hardcoded token on the Instabug.init
statement the only working option.
The env variable should also work and it should be enough, since hardcoding on Instabug.init
is not viable for some setups.