maxkomarychev / react-native-ultimate-config

Config that works
MIT License
262 stars 31 forks source link

Flavor mapping fails on app center build #27

Closed to-dy closed 4 years ago

to-dy commented 4 years ago

Describe the bug

Flavor mapping on appcenter build fails with file not found but works well locally

Steps to Reproduce

set up flavor mapping according to cook book (yaml file exists in repo)

project.ext.flavorEnvMapping = [
    dev: "../.env.yaml",
    staging: "../.env.staging.yaml"
]

Expected behavior

Expected Flavor mapping to be success full on appcenter (works locally)

Stacktraces, logs, screenshots

FAILURE: Build failed with an exception.

* Where:
Script '/Users/runner/runners/2.171.1/work/1/s/node_modules/react-native-ultimate-config/android/rnuc.gradle' line: 17

* What went wrong:
A problem occurred evaluating script.
> /Users/runner/runners/2.171.1/work/1/s/../.env.yaml (No such file or directory)

Environment

macos-10.15

Integration option

OS

Packages

Additional context

build works fine locally

maxkomarychev commented 4 years ago

@to-dy hi, can you please share more information on how exactly do you do build in appcenter? what command do you use? from which folder do you run it?

thanks.

to-dy commented 4 years ago

@maxkomarychev it's a Gradle task command can be found below

[command]/Users/runner/runners/2.171.1/work/1/s/android/gradlew -DAPPCENTER_KEYSTORE_PASSWORD=*** -DMOBILECENTER_KEYSTORE_PASSWORD=*** -DAPPCENTER_KEY_ALIAS=*** -DMOBILECENTER_KEY_ALIAS=*** -DAPPCENTER_KEY_PASSWORD=*** -DMOBILECENTER_KEY_PASSWORD=*** -DAPPCENTER_BUILD_VERSION=184 -DMOBILECENTER_BUILD_VERSION=184 -p android clean :app:assembleDevRelease :app:bundleDevRelease
Downloading https://services.gradle.org/distributions/gradle-6.1.1-all.zip
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Unzipping /Users/runner/.gradle/wrapper/dists/gradle-6.1.1-all/cfmwm155h49vnt3hynmlrsdst/gradle-6.1.1-all.zip to /Users/runner/.gradle/wrapper/dists/gradle-6.1.1-all/cfmwm155h49vnt3hynmlrsdst
Set executable permissions for: /Users/runner/.gradle/wrapper/dists/gradle-6.1.1-all/cfmwm155h49vnt3hynmlrsdst/gradle-6.1.1/bin/gradle

Welcome to Gradle 6.1.1!

Here are the highlights of this release:
 - Reusable dependency cache
 - Configurable compilation order between Groovy/Kotlin/Java/Scala
 - New sample projects in Gradle's documentation

For more details see https://docs.gradle.org/6.1.1/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)
Gradle 6.1.1

> Configure project :
Resolved com.android.tools.build:gradle:4.0.0 in :classpath 
Resolved com.google.gms:google-services:4.3.3 in :classpath 
Project myCareAI at : is either no Android app project or build version has not been set to override. Skipping...

> Configure project :app
Resolved org.yaml:snakeyaml:1.19 in classpath 
Flavor mapping detected: [dev:../.env.yaml, staging:../.env.staging.yaml]

FAILURE: Build failed with an exception.

* Where:
Script '/Users/runner/runners/2.171.1/work/1/s/node_modules/react-native-ultimate-config/android/rnuc.gradle' line: 17

* What went wrong:
A problem occurred evaluating script.
> /Users/runner/runners/2.171.1/work/1/s/../.env.yaml (No such file or directory)
maxkomarychev commented 4 years ago

would it be possible to see full piece of config relevant for this command? or any chance you are specifying custom cwd parameter there?

it looks like relative path is computed against root of the project instead of android folder. I don't have experience with appcenter so for now I can only speculate.

could you try changing your config to be

project.ext.flavorEnvMapping = [
    dev: ".env.yaml",
    staging: ".env.staging.yaml"
]

it might break the local build but I am wondering if this will do the trick for appcenter

meanwhile I'll try to think of more robust way of specifying path to config file.

maxkomarychev commented 4 years ago

ok I found the problem. gradle process is launched from root of the repository while existing code expects current working directory to be "android" folder. I am sure there is a simple fix to this issue.

to-dy commented 4 years ago

@maxkomarychev thanks for your time on this. 🙏🏾

maxkomarychev commented 4 years ago

@to-dy I have potential fix in branch "android-relative-paths" (pr https://github.com/maxkomarychev/react-native-ultimate-config/pull/28). I'll merge and publish it as soon as e2e is ok, you can meanwhile try installing it directly from the branch to give it a try.

thanks

maxkomarychev commented 4 years ago

@to-dy I have published new version 3.1.5 which should fix this problem. Please feel free to reopen if issue occurs again.

thanks for feedback.