Running prism in command line with environment vars of the project

(Nicolas Tisserand) #1

Hi everyone,

It’s possible to run Prism in commandline with a JSON file in the --env argument.
But, is it possible to run prism in commandline with environment variables from the .stoplight.yml file of the project AND in specifying the chosen environment name ?

Like this for example :
prism conduct "https://pathTo/tests.scenarios.yml" --env "https://pathTo/.stoplight.yml" --envName="staging"

This feature would be really useful. This feature would be really useful. Everything would be stored in the project and the variables values won’t be anymore in the job’s configuration of the CI/CD pipeline.

1 Like
(Thomas Pytleski) #2

@ntiss --env is a thing. --envName is not a thing. But you could do something like so:

--env "{someId}&branch={somebranch}&path=.stoplight.yml&pointer=/environments/staging"

Basically export your .stoplight file. Then add a query string named pointer, and it should start with a forward slash and then the path to your environment.

Let me know if you have questions.

1 Like
(Nicolas Tisserand) #3

Hi @bear

This is exactly what I wanted, thanks. (It should be included in your documentation here)

Unfortunately, I don’t manage this working in a single command line. The full url with query string works perfectly, but the env vars are empty when running the command all in one :

./prism conduct "{myId}&branch=version%2F1.0&path=tests.scenarios.yml" --env "{myId}&branch=version%2F1.0&path=.stoplight.yml&pointer=/environments/staging"
Prism version is 2.0.17
[Conductor] Stoplight API Host is

Todo CRUD Scenario (0.063s)
  Create Todo, POST %!B(MISSING)$$!D(MISSING)/todos?apikey={$$.env.todosApiKey} (0.014s)
     ✗  Expected output.status to equal 201 - actual is '0'
     before.variables.error ⁃ {$$} {$$.env.todosApiKey}
     after.logic.transforms.warn ⁃ Cannot find
     after.variables.error ⁃ {$$.env.todosApiKey}

To make it working, I have first to download the env and save as file, and then run prism like this :
./prism conduct "{myId}&branch=version%2F1.0&path=tests.scenarios.yml" --env theFile.json

(I use the latest release of prism)

(Thomas Pytleski) #4

@ntiss I will look into this today at some point, and let you know when we can get a fix out!

1 Like
(Nicolas Tisserand) #5

Hi @bear,
Some news about this, please ?

(Thomas Pytleski) #6

@ntiss sorry about the delayed response, we have created an issue and will be bringing it into an upcoming sprint. Will let you know when a fix has been released.



(Thomas Pytleski) #7

Actually quick question, is your project private? If so, and you are using prism login, there is an issue. Can you try creating a new Token in your user settings and using --token {token} in your command? You will want to copy the token that has this description: Use this token to authenticate with the Stoplight API and Prism:

(Nicolas Tisserand) #8

Hi @bear

No, my project is public.
It also tried with a token. Same behaviour. We’ll wait for the fix (onPrem also :wink: ).
Thank you for working on this.

(Thomas Pytleski) #9

@ntiss fix has been released, let us know if you have an issue still after updating.



1 Like
(Nicolas Tisserand) #10

Hi @bear
Thank you very much, it works fine !

1 Like