Problem
Some users observe the following error message when initially running jobs:
UnknownKey: No such environment variable: COMPUTERNAME
This problem can occur if example workflows have been used from JS7 - Download.
As a result some jobs of the example workflows fail with the above error message.
Analysis
The error message indicates that an environment variable with the name COMPUTERNAME
is used in a job. However this environment variable does not exist.
- The reason is with the JS7 - Job Resources from the archive
Defaults.zip
that is offered from JS7 - Download. After import this archive is extracted to a JOC Cockpit folder with the nameDefaults
and a job resource with the nameDefault
. Find details from JS7 - Job Environment Variables. The
Default
job resource includes an argument with the namejs7AgentHostname
and an environment variable with the nameJS7_AGENT_HOSTNAME
. By default the argument is assigned this value:js7AgentHostname = env('HOSTNAME', env('COMPUTERNAME'))
- The expression first makes use of a
HOSTNAME
environment variable (available for most Unix systems) and if this does not exist uses theCOMPUTERNAME
environment variable (available for Windows systems). Therefore running a job that makes use of theDefault
job resource on a Unix OS that does not provide theHOSTNAME
environment variable causes the error.
The assignment of the js7AgentHostname
argument is performed in the Configuration view for Job Resources like this:
Solution
Modify the value of the js7AgentHostname
argument like this:
js7AgentHostname = env('HOSTNAME', env('COMPUTERNAME', ""))
Explanation:
- The
env()
function makes use of two arguments: the first argument specifies an environment variable, the second argument specifies a default value should the environment variable not exist. - Adding an empty default value - specified by two double quotes - as provided from the above example resolves the problem.
- To apply changes deploy the job resource after modification.