Skip to content
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

Getting auth.token from .env #1888

Closed
fragilehm opened this issue Nov 14, 2021 · 6 comments
Closed

Getting auth.token from .env #1888

fragilehm opened this issue Nov 14, 2021 · 6 comments
Labels
Platform: React-Native Type: Feature Request up-for-grabs ✋ We would really appreciate anyone interested in working on this to submit a PR!
Projects

Comments

@fragilehm
Copy link

So right now I have sentry.properties file with auth.token filled in, in order to upload the source map. I understand that we can add this file to .gitignore not to expose the token to the remote repo. But we are using appcenter which also does build the release application so it needs to upload the sentry source map as well, but there is no option to get the auth.token from the specific file which is not in the repo, but we can set the env variables. So I was wondering if we could get the auth.token from .env instead or leave the default to get the variable from the sentry.properties file but in case it is not configured there, get it from .env something like:
"--auth-token", sentryProps.get("auth.token") ?: project.env.get("SENTRY_AUTH_TOKEN")

@marandaneto
Copy link
Contributor

kinda related to #831

@marandaneto
Copy link
Contributor

marandaneto commented Nov 15, 2021

ideally, we'd patch https://github.com/getsentry/sentry-react-native/blob/master/sentry.gradle#L108-L124 to not add the args in case they don't have a value, so sentry-cli would be able to read the env. var.

"--auth-token", sentryProps.get("auth.token") ?: project.env.get("SENTRY_AUTH_TOKEN")

would be a solution but sentry-cli already looks up into SENTRY_AUTH_TOKEN in case there's no --auth-token set, so in that case, we should just not add --auth-token if sentryProps.get("auth.token") returns nothing.
the same for url (SENTRY_URL), org (SENTRY_ORG) and project (SENTRY_PROJECT)

@fragilehm
Copy link
Author

@marandaneto that sounds much better indeed, any plans on doing that in the near future?

@marandaneto
Copy link
Contributor

@fragilehm we didn't define priorities yet, but it should not be super hard, what's about submitting a PR? would you be interested? I can guide with reviews

@marandaneto marandaneto added the up-for-grabs ✋ We would really appreciate anyone interested in working on this to submit a PR! label Nov 15, 2021
@kylegillen
Copy link

Has anyone made any progress on this or is there another way to use env variables over sentry.properties?

@krystofwoldrich
Copy link
Member

In the current version of RN SDK https://github.com/getsentry/sentry-react-native/releases/tag/5.6.0 and bundled Sentry CLI https://github.com/getsentry/sentry-cli/releases/tag/2.18.1 this works.

If auth token is present in sentry.properties it's used from the file. If not .env file is loaded and SENTRY_AUTH_TOKEN env is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: React-Native Type: Feature Request up-for-grabs ✋ We would really appreciate anyone interested in working on this to submit a PR!
Projects
Archived in project
Development

No branches or pull requests

5 participants