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

Set Global Environment Variables in Scripts #3821

Closed
1 task done
justinTangren opened this issue Jan 16, 2025 · 2 comments
Closed
1 task done

Set Global Environment Variables in Scripts #3821

justinTangren opened this issue Jan 16, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@justinTangren
Copy link

justinTangren commented Jan 16, 2025

I have checked the following:

  • I've searched existing issues and found nothing related to my issue.

Describe the feature you want to add

I would like the ability to update a global environment variable using a postRequest script and data from the response body

currently it is possible to update collection environement variables using a postRequest script and the setEnvVar method

bru.setEnvVar("access_token", res.getBody().token);

if the variable is already defined in a global environment, and does not exist in the collections environment; then the setEnvVar method will add a new variable to to the collections environment, and wont update the variable in the global environemt

Mockups or Images of the feature

I imagine a new method can be added that behaves like setEnvVar, but tagets global environments instead of collection environments

bru.setGlobalEnvVar("access_token", res.getBody().token);
@justinTangren justinTangren added the enhancement New feature or request label Jan 16, 2025
@justinTangren justinTangren changed the title Set Global Environment variables in scripts Set Global Environment Variables in Scripts Jan 16, 2025
@Its-treason
Copy link
Member

This feature is already implemented.

@justinTangren
Copy link
Author

justinTangren commented Jan 17, 2025

I never tried calling bru.setGlobalEnvVar(...) because there was no mention of it in the JavaScript API Reference documentation page. I assumed that it did not exist because the top of that page claims

Here is the complete set of API reference for the scripting feature in Bruno

I just tested calling bru.setGlobalEnvVar in a postRequest script and it worked.

The Documentation shoud be updated to include a reference to this method (should I create a new issue to update the documentation, or just edit the description of this issue?)

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

No branches or pull requests

2 participants