Problem getting Running Build Status via Server Side plugin

Hi,

I have a server-side plugin that is used to list running builds for a project/buildtype. Since 3.0, I do not get the same output as before.

Here is my code:

public void ListRunningBuilds(String project, String buildConfig) {
SProject bproj = myServer.getProjectManager().findProjectByName(project);
if (bproj == null) {
logger.error("Could not find project: " + project);
return;
}

SBuildType btype = bproj.findBuildTypeByName(buildConfig);
List]]> running = myServer.getRunningBuilds();
for (int t=0 ; t<running.size() ; t++) {
SRunningBuild rbi = running.get(t);
if (rbi.getBuildTypeId().equals(btype.getBuildTypeId())) {

long timeLeftEstimate = rbi.getEstimationForTimeLeft();
int percentComplete = rbi.getCompletedPercent();
String currentStage = "";
try {
BuildLog bl = rbi.getBuildLog();
if (bl != null) {
String tempStage = bl.getCurrentProgressText();
if (tempStage != null) {
currentStage = tempStage;
}
}
} catch (Exception e) {
// ignore
}
Status bs = rbi.getBuildStatus();
logger.debug(" Status : " + bs.getText());
logger.debug(" Build ID : " + rbi.getBuildNumber());
logger.debug(" %Complete : " + new Integer(percentComplete).toString());
logger.debug(" Time Left : " + new Long(timeLeftEstimate).toString());
logger.debug(" Stage : " + currentStage);
logger.debug(" AGENT : " + rbi.getAgentName());
break;
}
}

Here the 3.0 output when a build is RUNNING...

Status : NORMAL
Build ID : 1
%Complete : 0
Time Left : -1
Stage :
AGENT : PC3071

Can anyone confirm is this is correct way to get Running Build status?

Thanks,

Scott

1 comment

Hello,

If you want to display current build stage I think it is better to invoke
method:
SRunningBuild.getCurrentPath()

Also SRunningBuild.getBuildNumber() actually returns build number and not a
build id (build number is not unique, while the build id is unique among all
of the TC builds).

Probably you should use SBuildType.getRunningBuilds() method instead of
manually iterating over all running builds.

Time left and percent complete may have such values if build history of a
build configuration is empty or contains cancelled builds only.

As for differences between 3.0 and 2.X, could you please provide what output
did you expect?

Hope this helps.

--
Pavel Sher
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"



"Scott Hebert" <no_reply@jetbrains.com> wrote in message
news:3117733.1203537616624.JavaMail.itn@is.intellij.net...

Hi,

>

I have a server-side plugin that is used to list running builds for a
project/buildtype. Since 3.0, I do not get the same output as before.

>

Here is my code:

>

public void ListRunningBuilds(String project, String buildConfig) {
SProject bproj = myServer.getProjectManager().findProjectByName(project);
if (bproj == null) {
logger.error("Could not find project: " + project);
return;
}

>

SBuildType btype = bproj.findBuildTypeByName(buildConfig);
List<SRunningBuild> running = myServer.getRunningBuilds();
for (int t=0 ; t<running.size() ; t++) {
SRunningBuild rbi = running.get(t);
if (rbi.getBuildTypeId().equals(btype.getBuildTypeId())) {

>

long timeLeftEstimate = rbi.getEstimationForTimeLeft();
int percentComplete = rbi.getCompletedPercent();
String currentStage = "";
try {
BuildLog bl = rbi.getBuildLog();
if (bl != null) {
String tempStage = bl.getCurrentProgressText();
if (tempStage != null) {
currentStage = tempStage;
}
}
} catch (Exception e) {
// ignore
}
Status bs = rbi.getBuildStatus();
logger.debug(" Status : " + bs.getText());
logger.debug(" Build ID : " + rbi.getBuildNumber());
logger.debug(" %Complete : " + new Integer(percentComplete).toString());
logger.debug(" Time Left : " + new Long(timeLeftEstimate).toString());
logger.debug(" Stage : " + currentStage);
logger.debug(" AGENT : " + rbi.getAgentName());
break;
}
}

>

Here the 3.0 output when a build is RUNNING...

>

Status : NORMAL
Build ID : 1
%Complete : 0
Time Left : -1
Stage :
AGENT : PC3071

>

Can anyone confirm is this is correct way to get Running Build status?

>

Thanks,

>

Scott



0

Please sign in to leave a comment.