1

I want to use the environnement variables provided by jenkins (like Build_Id) as part of my robot script.
For eg:

user = "abc" + Build_Id

This is so that I can match my variable/value to a particular build.

Is there a way to use the env variables inside a Robot script?

Todor Minakov
  • 19,097
  • 3
  • 55
  • 60
Benoy John
  • 81
  • 2
  • 8

2 Answers2

3

You can easily access environment variables, in fact they are available in the cases/keywords scope just like a normal user-defined variable

${my var}=    Set Variable    abc %{BUILD_ID}

Note the access char is %, not $ as is for the user variables.

You can also use the keyword Get Environment Variable from the OperatingSystem library, which allows to have a default value if the env variable is not present, or fail the case/keyword.

Todor Minakov
  • 19,097
  • 3
  • 55
  • 60
2

Yes you can pass command line options as described here.

So, if you start RF via Jenkins shell execution do something like this:

robot --variable Build_Id:$Build_Id path/to/tests/

If you start RF indirectly by calling a script or maven or ant build script, you have to pass the variables accordingly (here is an example for maven).

Würgspaß
  • 4,660
  • 2
  • 25
  • 41