Skip to content

Commit

Permalink
Adds detail to polling log(#44)
Browse files Browse the repository at this point in the history
* Adds logs to interface compareRemoteRevision

* Changes on logging messages

Co-authored-by: José Lamas <jlr@genexus.com>
  • Loading branch information
nachob97 and jlamasrios authored Feb 27, 2024
1 parent bc2492a commit a5463ac
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import hudson.util.ListBoxModel;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
Expand Down Expand Up @@ -277,18 +278,30 @@ public DescriptorImpl getDescriptor() {
public PollingResult compareRemoteRevisionWith(@Nonnull Job<?, ?> project, @Nullable Launcher launcher,
@Nullable FilePath workspace, @Nonnull TaskListener listener, @Nonnull SCMRevisionState _baseline)
throws IOException, InterruptedException {
PrintStream logStream = listener.getLogger();

logStream.println("Starting GXserver polling");
final GXSRevisionState baseline = getSafeBaseline(project, launcher, workspace, listener, _baseline);
logStream.println("Baseline: Revision #" + baseline.getRevision() + " " + baseline.getRevisionDate());

try {
GXSConnection gxs = getGXSConnection(project);
GetLastRevisionTask getLastRevisionTask = new GetLastRevisionTask(listener, gxs, baseline.getRevisionDate(), new Date());
GXSInfo currentInfo = getLastRevisionTask.execute();
GXSRevisionState currentState = new GXSRevisionState(currentInfo.revision, currentInfo.revisionDate);

return new PollingResult(baseline, currentState,
currentState.getRevision() > baseline.getRevision() ? Change.SIGNIFICANT : Change.NONE);
Change stateChange = currentState.getRevision() > baseline.getRevision() ? Change.SIGNIFICANT : Change.NONE;
PollingResult result = new PollingResult(baseline, currentState, stateChange);

logStream.println("Current State: Revision #" + currentState.getRevision() + " " + currentState.getRevisionDate());
logStream.println("Changes on polling result: " + stateChange.toString());
logStream.println("GXserver Polling was completed successfully");

return result;
} catch (IOException | InterruptedException ex) {
listener.error("GXserver Polling failed: " + ex.toString());
listener.error(ex.getMessage());

logStream.println("GXserver polling returning 'BUILD_NOW' result due to error");
return PollingResult.BUILD_NOW;
}
}
Expand Down

0 comments on commit a5463ac

Please sign in to comment.