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

Perl API - environments variables

Hi,

I have a perl script that works with the Build Forge through the API.

I want to check if a value exist in one of my environment variable, and if not to add it.

I tried to look in the documentation, but i can't find it.

Please help,
Thanks
shiran

0 votes



11 answers

Permanent link
Hi,

With your information, I've modified the script. It worked for me.


use strict;

use BuildForge::Services;

my $host = 'localhost';
my $user = 'root';
my $password = 'root';
my $envName = 'TEST_ENV_1';
my $varName = 'TEST_VAR_1';
my $optionName = 'Model Office';
my $optionValue = 'MO';

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($varName);
die('Could not find env entry with name ' . $varName) unless defined($envEntry);

die('Env entry is not a pull down variable type entry') unless ($envEntry->getVariableType() eq 'PULLDOWN');

$envEntry = BuildForge::Services::DBO::EnvironmentEntry->findByUuid($conn, $envEntry->getUuid());
die('Could not find env entry by UUID') unless defined($envEntry);

my $envEntryOption = $envEntry->getOption($optionName);

if (!defined($envEntryOption)) {
$envEntryOption = new BuildForge::Services::DBO::EnvironmentEntryOption($conn);
$envEntryOption->setName($optionName);
$envEntryOption->setValue($optionValue);
$envEntryOption = $envEntryOption->update();
$envEntry->addOption($envEntryOption);
$envEntry = $envEntry->update();
print "Added env entry option named " . $optionName . " with value of " . $optionValue . " to env entry named " . $envEntry->getName() . ".\n";
} else {
print "The option " . $optionName . " already exists for variable " . $varName . " and contains value of " . $envEntryOption->getValue() . ".\n";
}

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


Hi,
every time i run this line:
my $env = BuildForge::Services::DBO::Environment->findByName
($conn, $envName);

I get Could not find env message, i tried with few of my environment but it happened with all of them, do you know what can be the problem?
I have installed a new BF server so the environment were imported to the new server.

Thanks,
shiran

Check to see if you can manually view the contents of the environment from the console. The relocation process may have missed the environments or the names may have changed slightly.

0 votes

1–15 items
page 2of 1 pagesof 2 pages

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: Oct 17 '10, 7:55 a.m.

Question was seen: 15,549 times

Last updated: Oct 17 '10, 7:55 a.m.

Confirmation Cancel Confirm