Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Reading Cloud Manager Environment Variables in Cypress UI test script

Avatar

Level 5

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

5 Replies

Avatar

Level 6

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.

Avatar

Level 5

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

Avatar

Level 6

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

 

Avatar

Level 5

That is valid question, It is running as the part of the Cloud pipeline so I'm not sure if env vars are available during pipeline run... so I would say that running on the same instance question is not the valid one ?

Regarding user having access, again not sure because it's part of the cloud pipeline

 

nbg62_0-1706692277782.png

 

Avatar

Administrator

@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