Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 0a6ee8f

Browse files
committed
Improve logging of path errors.
1 parent cfad2f0 commit 0a6ee8f

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

plugin/src/main/java/io/jenkins/plugins/coverage/metrics/source/SourceCodePainter.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ private Optional<FilePath> findSourceFile(final FilePath workspace, final String
222222
if (relativePath.exists()) {
223223
return Optional.of(relativePath);
224224
}
225-
226-
log.logError("Source file '%s' not found", fileName);
227225
}
228226
catch (InvalidPathException | IOException | InterruptedException exception) {
229227
log.logException(exception, "No valid path in coverage node: '%s'", fileName);

plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/PathResolver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static class AgentPathResolver extends MasterToSlaveFileCallable<RemoteResultWra
105105
@Override
106106
public RemoteResultWrapper<HashMap<String, String>> invoke(
107107
final File workspaceFile, final VirtualChannel channel) {
108-
FilteredLog log = new FilteredLog("-");
108+
FilteredLog log = new FilteredLog("Errors while resolving source files on agent:");
109109

110110
Set<String> sourceDirectories = filterSourceDirectories(workspaceFile, log);
111111
if (sourceDirectories.isEmpty()) {
@@ -169,7 +169,7 @@ private Optional<String> locateSource(final String relativePath, final FilePath
169169
}
170170
}
171171

172-
log.logError("Source file '%s' not found", relativePath);
172+
log.logError("- Source file '%s' not found", relativePath);
173173
}
174174
catch (InvalidPathException | IOException | InterruptedException exception) {
175175
log.logException(exception, "No valid path in coverage node: '%s'", relativePath);
@@ -189,7 +189,7 @@ private Optional<String> enforcePermissionFor(final FilePath absolutePath, final
189189
return Optional.of(PATH_UTIL.getAbsolutePath(fileName));
190190
}
191191
}
192-
log.logError("Skipping resolving of file: %s (not part of workspace or permitted source code folders)",
192+
log.logError("- Skipping resolving of file: %s (not part of workspace or permitted source code folders)",
193193
fileName);
194194
return Optional.empty();
195195
}

plugin/src/test/java/io/jenkins/plugins/coverage/metrics/source/SourceCodeITest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ void coveragePluginPipelineNotRegisteredSourceCodeDirectory() throws IOException
9393
.contains("-> finished painting (0 files have been painted, 1 files failed)")
9494
.contains(String.format(
9595
"[-ERROR-] Removing source directory '%s' - it has not been approved in Jenkins' global configuration.",
96-
sourceDirectory));
96+
sourceDirectory))
97+
.contains("- Source file '" + ACU_COBOL_PARSER_SOURCE_FILE_PATH + "' not found");
9798

9899
verifySourceCodeInBuild("", firstBuild, NO_SOURCE_CODE, NO_SOURCE_CODE); // should be still available
99100
localAgent.setLabelString("<null>");

0 commit comments

Comments
 (0)