Skip to content

dotenv CI/CD: XCode Cloud - how to define env vars ? Android appbundle - how to define env vars ? #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
iKK001 opened this issue Jan 24, 2024 · 2 comments

Comments

@iKK001
Copy link

iKK001 commented Jan 24, 2024

I am using flutter_dotenv 5.1.0

Everything works if I compile my flutter app locally:

import 'package:flutter_dotenv/flutter_dotenv.dart';

// Load .env file
await dotenv.load(fileName: '.env');

// Initialize Stripe
String myKey = dotenv.env['MY_KEY']!;

But how does it work for Xcode Cloud CI ??

And how for Google Playstore (appbundle) ??

For XCode Cloud:

I am using the default ci_post_clone.sh as described here in the official Flutter documentation.

What do I need to add to this ci_post_clone.sh script in order to make the environment variables defined in .env work.

(And I do not want to add .env to git)


For XCode Cloud, I also tried to directly mention the env vars in the XCode mask (under Intergrate Workflows)
Screenshot 2024-01-24 at 20 23 04

But it does not work - Apple still throws the error that .env cannot be found under /assets/.env .

Screenshot 2024-01-24 at 20 30 51

How can I use .env in Flutter and still use XCode Cloud CI ??

For Android I am clueless. Any idea ? (I'm using flutter build appbundle)

@iKK001 iKK001 changed the title dotenv CI/CD: XCode Cloud - how to define env vars ? Android appBuild - how to define env vars ? dotenv CI/CD: XCode Cloud - how to define env vars ? Android appbundle - how to define env vars ? Jan 24, 2024
@BirgitPohl
Copy link

I'm facing the same issue with a different use case.
I'm trying to run flutter test on Github actions without loading the .env into my repo.
My tests fail because the pubspec.yaml is expecting a .env file at the expected location. The command did not even touch test settings or any test file.

one can reproduce this situation locally, by temporarily removing the .env or changing the name) from their project and trying to run their tests.

@mahdiyarz
Copy link

I'm facing the same issue with a different use case. I'm trying to run flutter test on Github actions without loading the .env into my repo. My tests fail because the pubspec.yaml is expecting a .env file at the expected location. The command did not even touch test settings or any test file.

one can reproduce this situation locally, by temporarily removing the .env or changing the name) from their project and trying to run their tests.

I have the same issue too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants