Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

.set of a non-existent variable

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

0 votes



3 answers

Permanent link
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.

0 votes


Permanent link
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

0 votes


Permanent link

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

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Nov 16 '10, 4:40 p.m.

Question was seen: 3,769 times

Last updated: Nov 16 '10, 4:40 p.m.

Confirmation Cancel Confirm