It's all about the answers!

Ask a question

.set of a non-existent variable


Tim McDaniel (401146) | asked Nov 16 '10, 4:40 p.m.
In the help for ".set":

.set env <EnvGroupName> "<VariableName>=<DesiredValue>"

...
Note: Variables set by this command must already exist.
...

Is there *any* way to get around this so I can .set a permanent
variable in an environment that was not set at the start of the job?

--
Tim McDaniel, tmcd@panix.com

3 answers



permanent link
Robert haig (1.0k16) | answered Dec 08 '10, 2:07 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
In the help for ".set":

.set env <EnvGroupName> "<VariableName>=<DesiredValue>"

...
Note: Variables set by this command must already exist.
...

Is there *any* way to get around this so I can .set a permanent
variable in an environment that was not set at the start of the job?

--
Tim McDaniel, tmcd@panix.com


you could call an api program to create the variable before you .set it. But the variable must exist before you call .set. There's not a way around it using the .set command.

permanent link
Tim McDaniel (401146) | answered Apr 12 '11, 7:20 a.m.
In article <idol2o>,
rhaig <rhaig> wrote:
Tim McDanielwrote:
In the help for ".set":

.set env <EnvGroupName>
"<VariableName>=<DesiredValue>"

...
Note: Variables set by this command must already exist.
...

Is there *any* way to get around this so I can .set a permanent
variable in an environment that was not set at the start of the
job?

you could call an api program to create the variable before you .set
it.

I finally found the Perl API documentation. I see methods to read
environment variables, but nothing on how to create or set them.

--
Tim McDaniel, tmcd@panix.com

permanent link
Brent Ulbricht (2.5k11) | answered Apr 13 '11, 1:11 p.m.
JAZZ DEVELOPER

I finally found the Perl API documentation. I see methods to read
environment variables, but nothing on how to create or set them.


Hi Tim,

I've added an example of how to create an environment variable.


use strict;

use BuildForge::Services;

my $host = 'localhost';
my $user = 'root';
my $password = 'root';
my $envName = 'TEST_ENV_1';
my $envEntryName = 'TEST_VAR_1';
my $envEntryValue = "TEST_VAR_1_VAL";

my $conn = new BuildForge::Services::Connection($host);
my $token = $conn->authUser($user, $password);

my $env = BuildForge::Services::DBO::Environment->findByName($conn, $envName);
die('Could not find env ' . $envName) unless defined($env);

my $envEntry = $env->getEntry($envEntryName);
if (!defined($envEntry)) {
$envEntry = new BuildForge::Services::DBO::EnvironmentEntry($conn);
$envEntry->setName($envEntryName);
$envEntry->setValue($envEntryValue);
$envEntry->setAction('SET');
$envEntry->setMode('NORMAL');
$env->addEnvironmentEntry($envEntry);
$env->update();
print "Variable " . $envEntryName . " added to environment group " . $envName . "\n";
} else {
print "Variable " . $envEntryName . " already exists in the environment group " . $envName . "\n";
}

$conn->logout();
$conn->close();


Brent Ulbricht
Developer/Lead - RTC Build

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.