Runtime variables
How to define runtime variables and use them inside lifecycle scripts or challenge assignments.
Overview
Runtime variables allow you to use dynamic content in challenge assignments and lifecycle scripts. You can define runtime variables via our API or Lifecycle Scripts. These variables are configured per participant per host (e.g a user's VM or container) and can only be accessed from the given participant and host.
Set variables
Define variables
You can define variables in lifecycle scripts on Linux and Windows hosts:
agent variable set <KEY> <VALUE>For example, the following defines a runtime variable named COLOR with a value of RED.
agent variable set COLOR REDAgent-Variable-Set <KEY> <VALUE>For example, the following defines a runtime variable named COLOR with a value of RED.
Agent-Variable-Set COLOR REDRetrieve variables
In order to retrieve the value of a runtime variable, use the following command:
agent variable get {KEY}For example, the following retrieves a runtime variable named COLOR.
agent variable get COLORAgent-Variable-Get {KEY}For example, the following retrieves a runtime variable named COLOR.
Agent-Variable-Get COLORUse variables
To retrieve the value of a runtime variable in a challenge assignment use following syntax:
[[ Instruqt-Var key="<KEY>" hostname="<HOSTNAME>" ]]Where KEY is a key you registered a value with and HOSTNAME is a host where the variable resides.
Example
Consider the following challenge assignment, which references a runtime variable named INSTRUQT_TEST_VAR on a host named cloud-client.
👋 Introduction
===============
The following line contains the value of INSTRUQT_TEST_VAR:
[[ Instruqt-Var key="INSTRUQT_TEST_VAR" hostname="cloud-client" ]]Assuming INSTRUQT_TEST_VAR was registered with a value of TEST123 on the cloud-client host during its setup script, the assignment text would display TEST123 to the user.
Last updated
Was this helpful?