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.


(Thomas Pytleski) #2

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

--env "https://next-api.stoplight.io/files.export?projectId={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.


(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 "https://next-api.stoplight.io/files.export?projectId={myId}&branch=version%2F1.0&path=tests.scenarios.yml" --env "https://next-api.stoplight.io/files.export?projectId={myId}&branch=version%2F1.0&path=.stoplight.yml&pointer=/environments/staging"
Prism version is 2.0.17
[Conductor] Stoplight API Host is https://next-api.stoplight.io

Todo CRUD Scenario (0.063s)
  Create Todo, POST %!B(MISSING)$$.env.host%!D(MISSING)/todos?apikey={$$.env.todosApiKey} (0.014s)
     ✗  Expected output.status to equal 201 - actual is '0'
     before.variables.error ⁃ {$$.env.host} {$$.env.todosApiKey}
     after.logic.transforms.warn ⁃ Cannot find output.body.id.
     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 "https://next-api.stoplight.io/files.export?projectId={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!