It's all about the answers!

Ask a question

Perl API: How to get the EXEC message when build fails


Jirong Hu (1.5k9295258) | asked Nov 17 '12, 12:42 p.m.
edited Nov 17 '12, 12:56 p.m.
 https://jazz.net/library/content/articles/build-forge/7.1.2/api/RationalBuildForge_GettingStartedAPI.pdf

I am using the Perl API to execute BF project within a ClearCase trigger (command line). I want to retrieve the error message listed in EXEC step result when a build fails, so that can be displayed to the end user in ClearCase.

Below is my code, what function shall I call to get the EXEC result, the message/log of the failed step?

Thanks
Jirong

  ######################## Fire the build and wait for it to finish ######################
   print "--------------------------------------\n";
   print "Firing build and waiting for completion...\n";
   $build = $build->fireBuild();
   while($build->getState() ne "COMPLETED"){
       sleep 5;
       $build = BuildForge::Services::DBO::Build->findByUuid($conn, $build->getUuid());
   }
   print "Build finished...\n";
   
   ###################### Check results ################################
   if($build->getResult() eq "PASSED") {
       print "Build passed!\n";
       print "--------------------------------------\n";
       print "Information for: ".$build->getTag()."\n";
       print "\tParent project: ".$projectName."\n";
       print "\tClass: ".BuildForge::Services::DBO::BuildClass->findByUuid($conn, $build->getBuildClassUuid())->getName()."\n";
       print "\tBuild environment:\n";
       $buildEnvEntries = BuildForge::Services::DBO::BuildEnvironment->findByUuid($conn, $buildEnvUuid)->getEntries();
       foreach my $buildEnvEntry (@$buildEnvEntries) {
           print "\t\t".$buildEnvEntry->getName()." = ".$buildEnvEntry->getValue()."\n";
       }
       print "\tDuration: ".$build->getDuration()." seconds\n";
       return 0;
   }
   else {
       print "Build failed!\n";
       return 1;
   }
}

2 answers



permanent link
Jirong Hu (1.5k9295258) | answered Nov 26 '12, 7:17 p.m.
edited Nov 26 '12, 8:27 p.m.
Anybody know this? 

I opened a PMR to IBM (give them the link to this post) and got the following answer!!! What kind of people IBM hired for the support?! The first level support always play this game recently: never give you an answer then after a while asking you why you didn't reply. Are all these support now out-sourced?

Hi Jirong,

I wanted to follow up with you to see what questions you may have about my last email? 

Here is the email text for your reference:
---
Hello,

My name is Ryan Ruscett and I have been assigned to your PMR to help
answer your questions and or assist you with your concerns. I have
received your email and I am currently looking into the issue.

You can access the entire list of api methods via
//(servername)/clients. That should pull up the Perl API information.
From there you can search all available methods.

The API is not an out of the box feature with Build Forge so there is
limited support for it. I will get back to you as soon as I have
something more solid for you.


---

I understand you may be busy, therefore could you please provide an estimate on when you may be able to FILL IN DETAILS AS TO WHAT WE NEED  so we can best plan to work on this issue.

If you are having trouble with FILL IN A SUMMARY OF WHAT WE ARE ASKING FOR, let me know what I can do to help.   

If I do not hear from you by Wed, Nov 28th, reach out to you again. 

permanent link
Spencer Murata (2.3k115971) | answered Nov 27 '12, 1:14 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
 From the build object, you need to use getResults() to get the Result objects from the build, then you need to find the specific step results you are interested in, possibly by the Result method getDescription() or getStepUUID() if you have that information.  The Result method  getLogs() will return Log objects for each line of the result log.  You can then sort the type of Log objects by using getType() and filtering for EXEC.

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.