It's all about the answers!

Ask a question

Dot commands


sridevi yv (10632) | asked Aug 12 '10, 4:33 a.m.
hi,
i have to launch a project on the failure of a step of another project and after that the failed step has to be re-executed.. so i can set the project to be lauched in fail chain field and use .retry command in the last step of the called project.
but .retry command takes only script names as arguments..can i use project names or step names which have previously failed as arguments? wat can do abt this??

22 answers



permanent link
Johnson Joseph (811) | answered Aug 31 '10, 3:34 p.m.
Bju,
Again thanks for the help. On this perl script email message could we add the environment variables from build forge project ?
We have 8 environment variables on each project so is that possible to get the variables into email message like $URL,$PROJECTNAME from the build forge project

Thanks
Johnson



Bju,
Thanks for the help. Lets hope will get the answer as soon as possible from dev team. Is there any other way to send an email to team for the pass notify?

Once again thanks for the help

Thanks
Johnson


Hi Johnson,

You might want to just use the MIME::Lite package directly to send an email instead of using a Build Forge feature. I have attached the script that we've been working with that contains a few lines at the bottom to send an email using MIME::Lite. You'll have to modify the variables to your liking (ex. to, from, message, etc.).


You'll also need to make sure that your system has the MIME::Lite package. You can use cpan to retrieve it if you don't have it.



#!/usr/bin/perl
use strict;

use BuildForge::Services;

use MIME::Lite;

my $conn = new BuildForge::Services::Connection('localhost');
my $token = $conn->authUser('root', 'root');

my $projectName = 'EMBEDAPAT_TEST';
my $project = BuildForge::Services::DBO::Project->findByName($conn, $projectName);
die("Could not find project named: " . $projectName) unless defined($project);

my $newBuild = BuildForge::Services::DBO::Build->create($conn, $project->getUuid());
die("Could not create build for project: " . $project->getName()) unless defined($newBuild);

my $buildEnvUuid = $newBuild->getBuildEnvUuid();
die("Did not get build env uuid") unless defined($buildEnvUuid);

my $buildEnv = BuildForge::Services::DBO::BuildEnvironment->findByUuid($conn, $buildEnvUuid);
die("Could not find build environment uuid: " . $buildEnvUuid) unless defined($buildEnv);

my $myEnvVar = 'BUILDFILE';
my $buildEnvEntry = $buildEnv->getEntry($myEnvVar);
die("Could not get build env entry named: " . $myEnvVar) unless defined($buildEnvEntry);

my $oldBuildEnvEntryVal = $buildEnvEntry->getValue();
my $newBuildEnvEntryVal = 'Install/KING/EMBEDA_PAT/100811/100818_build_nosql.xml';
$newBuild->updateBuildEnvEntryValue($buildEnvEntry->getUuid(), $newBuildEnvEntryVal);
print "Changed build env entry val from " . $oldBuildEnvEntryVal . " to " . $newBuildEnvEntryVal . "\n";

$newBuild = $newBuild->fireBuild();

my $timeOut = 300;

my $buildState = $newBuild->getState();

for (my $i = 0; ($i <timeOut>findByUuid($conn, $newBuild->getUuid());
die("Could not get the build") unless defined($newBuild);
$buildState = $newBuild->getState();
my $results = $newBuild->getResults();
die("Could not get the results for the build") unless defined($results);
print $i . ": Project Name: " . $projectName . "\tTag: " . $newBuild->getTag() . "\tState: " . $newBuild->getState() . "\n";
foreach my $result (@$results) {
print "\tStep Description: " . $result->getDescription() . "\tStep Result: " . $result->getResult() . "\n";
}
print "\n";
}

die("Build did not complete in under " . $timeOut . " seconds.") if ($buildState ne 'COMPLETED');

print "Final Build Result: " . $newBuild->getResult() . "\n";

my $to = "build.recipient\@my.company.com";
my $from = "buildforge\@my.company.com";
my $subject = "Build Status: " . $newBuild->getResult();
my $message = "The result of the build was " . $newBuild->getResult() . ".";

my $msg = MIME::Lite->new(From => $from, To => $to, Subject => $subject, Data => $message);
MIME::Lite->send('smtp', 'localhost', Timeout => 60);
$msg->send();


bju

permanent link
Brent Ulbricht (2.5k11) | answered Aug 31 '10, 10:20 p.m.
JAZZ DEVELOPER
Bju,
Again thanks for the help. On this perl script email message could we add the environment variables from build forge project ?
We have 8 environment variables on each project so is that possible to get the variables into email message like $URL,$PROJECTNAME from the build forge project

Thanks
Johnson


Hi,

Yes, it's possible to add variables to the email. It really just depends on what variables you would like as to which API you need to get them.

The code example below gets build environment variables. However, you may want other variables that may be less build dependent, and you can just query other object APIs directly to get those values.


my $buildEnvUuid = $newBuild->getBuildEnvUuid();
die("Did not get build env uuid") unless defined($buildEnvUuid);

my $buildEnv = BuildForge::Services::DBO::BuildEnvironment->findByUuid($conn, $buildEnvUuid);
die("Could not find build environment uuid: " . $buildEnvUuid) unless defined($buildEnv);

my $myEnvVar = 'MY_VAR';
my $buildEnvEntry = $buildEnv->getEntry($myEnvVar);
die("Could not get build env entry named: " . $myEnvVar) unless defined($buildEnvEntry);

my $emailVar = $buildEnvEntry->getValue();


bju

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.