Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Environment Variables in Hurl files #122

Closed
fabricereix opened this issue Jan 11, 2021 · 1 comment · Fixed by #352
Closed

Using Environment Variables in Hurl files #122

fabricereix opened this issue Jan 11, 2021 · 1 comment · Fixed by #352
Labels
enhancement New feature or request
Milestone

Comments

@fabricereix
Copy link
Collaborator

How to use environment variables in hurl files?

option 1

Explicitly by prefixing your variables with env

for example

GET {{env.url}}
@fabricereix fabricereix added the enhancement New feature or request label Jan 11, 2021
@fabricereix
Copy link
Collaborator Author

We will use another option (suggested by @tbolon in #290)

Variables in Hurl will be set by default from environment variables HURL_xxx.

$ echo 'GET {{url}}' | hurl 
error: Undefined Variable
  --> -:1:7
   |
 1 | GET {{url}}
   |       ^^^ You must set the variable url
   |
$ export HURL_url=http://google.com
$ echo 'GET {{url}}' | hurl 
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

And they can be overriden by the the command-line option --variable.

$ echo 'GET {{url}}' | hurl --variable "url=toto" 
error: Http Connection
  --> -:1:5
   |
 1 | GET {{url}}
   |     ^^^^^^^ (6) Could not resolve host: toto
   |

This is similar to setting the proxy from environment variable http_proxy or command-line option --proxy.

@fabricereix fabricereix linked a pull request Nov 11, 2021 that will close this issue
@fabricereix fabricereix added this to the 1.5.0 milestone Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant