Skip to main content
Level 4
Jan 30, 2024 4:55 PM UTC

Reading Cloud Manager Environment Variables in Cypress UI test script

hi all,

 

I'm struggling to find a way to read env. variables set on the cloud manager configuration and provide them in cypress script during pipeline execution.

Also, another option would be to define vars as part of the osgiconfig module and access it from there.

 

Thank you

6 replies

kaikubad
Community Advisor
Community Advisor
Jan 31, 2024 5:43 AM UTC

Two possible lines that I can suggest.

1.

const myVariable = process.env.MY_VARIABLE;

2.

const myVariable = Cypress.env('MY_VARIABLE');

 For testing set env variable on your local and try to read with one of the line.

Cloud manager env variables are like other env variables. You can read it if your application is running on the same instance.

Translate
mkaikubad
nbg62Author
Level 4
Jan 31, 2024 8:39 AM UTC

Thank you,

 

I believe this doesn't work because we have it used in the same way, it's always taking localhost one. 

 

const authorURL = process.env.AEM_AUTHOR_URL || "http://localhost:4502";

 

We used cypress sample from the Weekend git, config is defined under, cypress.config.js

Translate
kaikubad
Community Advisor
Community Advisor
Jan 31, 2024 8:42 AM UTC

Is it running on same instance?
and do the user have access to read all env variables? because adobe gives specific permission to user

 

Translate
mkaikubad
kautuk_sahni
Level 9
Feb 21, 2024 11:48 AM UTC

@nbg62 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Translate
Kautuk Sahni