Skip to content

Commit 52f5a90

Browse files
committed
Adding a sample gradle task to upload mapping files to Instabug Backend to be run and included in the CI release process
1 parent 7cb3225 commit 52f5a90

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

app/build.gradle

+13-4
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,20 @@ dependencies {
5656
//implementation 'io.reactivex:rxjava:1.0.13'
5757
//implementation 'io.reactivex:rxandroid:1.0.1'
5858
implementation("com.instabug.library:instabug:$rootProject.ext.instabugSDK") {
59-
// TODO uncomment this line to exclude RxJava from Instabug and use your own version
60-
// exclude group: 'io.reactivex'
59+
// TODO uncomment this line to exclude RxJava from Instabug and use your own version
60+
// exclude group: 'io.reactivex'
6161

62-
// TODO uncomment next line if you're facing compilation issue in build.gradle about gms different versions
63-
//exclude group: 'com.android.support'
62+
// TODO uncomment next line if you're facing compilation issue in build.gradle about gms different versions
63+
//exclude group: 'com.android.support'
6464
}
6565
implementation "petrov.kristiyan:colorpicker-library:$rootProject.ext.colorPicker"
6666
}
67+
68+
69+
task uploadMappingFiles(type: Exec) {
70+
android.applicationVariants.all {
71+
if (it.variantData.variantConfiguration.buildType.name == "release" && it.mappingFile != null && it.mappingFile.exists()) {
72+
commandLine 'sh', '../upload_mapping.sh', "APP_TOKEN", it.versionCode, it.versionName, it.mappingFile
73+
}
74+
}
75+
}

upload_mapping.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
APP_TOKEN=$1
4+
VERSION_CODE=$2
5+
VERSION_NAME=$3
6+
PATH_TO_MAPPING_FILE=$4
7+
8+
echo "Instabug mapping files uploader"
9+
10+
VERSION='{"code":"'"$VERSION_CODE"'","name":"'"$VERSION_NAME"'"}'
11+
12+
if [ ! -f $PATH_TO_MAPPING_FILE ]; then
13+
echo "File not found!"
14+
exit 0
15+
fi
16+
17+
echo "Mapping file found! Uploading..."
18+
19+
ENDPOINT="https://api.instabug.com/api/sdk/v3/symbols_files"
20+
STATUS=$(curl "${ENDPOINT}" --write-out %{http_code} --silent --output /dev/null -F os=android -F app_version="${VERSION}" -F symbols_file=@"${PATH_TO_MAPPING_FILE}" -F application_token="${APP_TOKEN}")
21+
if [ $STATUS -ne 200 ]; then
22+
echo "Error while uploading mapping files"
23+
exit 0
24+
fi
25+
26+
27+
echo "Success! Your mapping files got uploaded successfully"

0 commit comments

Comments
 (0)