When building a regular Android app with Gradle, I can add params as such:
./gradlew assembleRelease -Pusername=foo -Ppassword=bar
With Flutter, this is what I'm supposed to call in order to assemble an APK:
flutter build apk
How do I pass the params to Gradle in this case?
P.S. I'm trying to use Jenkins credentials in a pipeline configuration. I do not want to expose my password, so avoiding using the arguments and putting it directly into the project is not an option.
You can pass variables via the environment, I use this method with Jenkins. The job can be configured to pass the credentials via environment variables.
In your build.gradle
(where needed):
username = System.getenv('SECRET_USERNAME')
password = System.getenv('SECRET_PASSWORD')
Please notice that System.getenv(...)
returns null
if the variable is not defined.
In your development environment you should export the variables:
$ export SECRET_USERNAME="my secret username"
$ export SECRET_PASSWORD="my super secret password"
Please, I do not know which IDE are you using, but both IntelliJ and AndroidStudio do support declaring environment variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With