Skip to content

Commit

Permalink
[JENKINS-44088] better troubleshooting messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyrille Le Clerc committed May 10, 2017
1 parent 3f76ea4 commit d9736e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Expand Up @@ -23,6 +23,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -81,9 +82,10 @@ public void process(@Nonnull StepContext context, @Nonnull Element mavenSpyLogsE
mavenArtifact.getFileName();

String artifactPathInWorkspace = XmlUtils.getPathInWorkspace(mavenArtifact.file, workspace);

if (StringUtils.isEmpty(artifactPathInWorkspace)) {
listener.error("[withMaven] Invalid path in the workspace (" + workspace.getRemote() + ") for artifact " + mavenArtifact);
} else if (Objects.equals(artifactPathInArchiveZone, mavenArtifact.file)) { // troubleshoot JENKINS-44088
listener.error("[withMaven] Failed to relativize '" + mavenArtifact.file + "' in workspace '" + workspace.getRemote() + "' with file separator '" + fileSeparatorOnAgent + "'");
} else {
FilePath artifactFilePath = new FilePath(workspace, artifactPathInWorkspace);
if (artifactFilePath.exists()) {
Expand All @@ -93,7 +95,7 @@ public void process(@Nonnull StepContext context, @Nonnull Element mavenSpyLogsE
String artifactDigest = artifactFilePath.digest();
artifactsToFingerPrint.put(artifactPathInArchiveZone, artifactDigest);
} else {
listener.getLogger().println("[withMaven] FAILURE to archive " + artifactPathInWorkspace + " under " + artifactPathInArchiveZone + ", file not found");
listener.getLogger().println("[withMaven] FAILURE to archive " + artifactPathInWorkspace + " under " + artifactPathInArchiveZone + ", file not found in workspace " + workspace);
}
}
} catch (IOException | RuntimeException e) {
Expand All @@ -103,7 +105,7 @@ public void process(@Nonnull StepContext context, @Nonnull Element mavenSpyLogsE
}
}
if (LOGGER.isLoggable(Level.FINE)) {
listener.getLogger().println("[withMaven] Archive and fingerprint " + artifactsToArchive);
listener.getLogger().println("[withMaven] Archive and fingerprint artifacts " + artifactsToArchive + " located in workspace " + workspace.getRemote());
}

// ARCHIVE GENERATED MAVEN ARTIFACT
Expand Down
Expand Up @@ -177,6 +177,8 @@ public static List<Element> getExecutionEvents(@Nonnull Element mavenSpyLogs, St
}

/**
* Relativize path
*
* @return same path if not matching workspace
*/
@Nonnull
Expand Down Expand Up @@ -213,7 +215,6 @@ public static String getFileSeparatorOnRemote(@Nonnull FilePath filePath) {
} else {
return "\\";
}

}

/**
Expand Down

0 comments on commit d9736e6

Please sign in to comment.