Reading Cloud Manager Environment Variables in Cypress UI test script | Community
Skip to main content
Level 4
January 30, 2024

Reading Cloud Manager Environment Variables in Cypress UI test script

  • January 30, 2024
  • 2 replies
  • 1426 views

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

2 replies

kaikubad
Community Advisor
Community Advisor
January 31, 2024

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.

nbg62Author
Level 4
January 31, 2024

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

kaikubad
Community Advisor
Community Advisor
January 31, 2024

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

 

kautuk_sahni
Community Manager
Community Manager
February 21, 2024

@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.

Kautuk Sahni