Skip to content

Commit

Permalink
Include all logs (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
sleiss authored Sep 10, 2022
1 parent f9e1835 commit 33fb07d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.tum.in.www1</groupId>
<artifactId>bamboo-server</artifactId>
<version>1.6.0</version>
<version>1.7.0</version>
<organization>
<name>LS1 TUM</name>
<url>https://ase.in.tum.de</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

import com.atlassian.bamboo.artifact.MutableArtifact;
import com.atlassian.bamboo.build.BuildLoggerManager;
import com.atlassian.bamboo.build.BuildOutputLogEntry;
import com.atlassian.bamboo.build.ErrorLogEntry;
import com.atlassian.bamboo.build.LogEntry;
import com.atlassian.bamboo.build.artifact.ArtifactLink;
import com.atlassian.bamboo.build.artifact.ArtifactLinkDataProvider;
Expand Down Expand Up @@ -96,7 +94,7 @@ public class ServerNotificationTransport implements NotificationTransport {
private static final int JOB_LOG_MAX_LINES = 5000;

// We are only interested in logs coming from the build, not in logs from Bamboo
final List<Class<?>> logEntryTypes = ImmutableList.of(BuildOutputLogEntry.class, ErrorLogEntry.class);
final List<Class<?>> logEntryTypes = ImmutableList.of(LogEntry.class);

public ServerNotificationTransport(String webhookUrl, @Nullable ImmutablePlan plan, @Nullable ResultsSummary resultsSummary, CustomVariableContext customVariableContext,
@Nullable BuildLoggerManager buildLoggerManager, @Nullable BuildLogFileAccessorFactory buildLogFileAccessorFactory) {
Expand Down Expand Up @@ -344,18 +342,16 @@ private JSONObject createJSONObject(Notification notification) {
}
List<LogEntry> logEntries = Collections.emptyList();

// Only add log if no tests are found (indicates a build error)
if (testResultsSummary.getTotalTestCaseCount() == 0) {
// Loading logs for job
try {
final BuildLogFileAccessor fileAccessor = this.buildLogFileAccessorFactory.createBuildLogFileAccessor(buildResultsSummary.getPlanResultKey());
logEntries = fileAccessor.getLastNLogsOfType(JOB_LOG_MAX_LINES, logEntryTypes);
LoggingUtils.logInfo("Found: " + logEntries.size() + " LogEntries", buildLoggerManager, plan.getPlanKey(), log);
}
catch (IOException ex) {
LoggingUtils.logError("Error while loading build log: " + ex.getMessage(), buildLoggerManager, plan.getPlanKey(), log, ex);
}
// Loading logs for job
try {
final BuildLogFileAccessor fileAccessor = this.buildLogFileAccessorFactory.createBuildLogFileAccessor(buildResultsSummary.getPlanResultKey());
logEntries = fileAccessor.getLastNLogsOfType(JOB_LOG_MAX_LINES, logEntryTypes);
LoggingUtils.logInfo("Found: " + logEntries.size() + " LogEntries", buildLoggerManager, plan.getPlanKey(), log);
}
catch (IOException ex) {
LoggingUtils.logError("Error while loading build log: " + ex.getMessage(), buildLoggerManager, plan.getPlanKey(), log, ex);
}

JSONArray logEntriesArray = new JSONArray();
for (LogEntry logEntry : logEntries) {
// A lambda here would require us to catch the JSONException inside the lambda, so we use a loop.
Expand Down

0 comments on commit 33fb07d

Please sign in to comment.