Skip to content

Instantly share code, notes, and snippets.

@fguchelaar
Created March 15, 2016 09:38
Show Gist options
  • Save fguchelaar/92f25f3931fdf0e44dd1 to your computer and use it in GitHub Desktop.
Save fguchelaar/92f25f3931fdf0e44dd1 to your computer and use it in GitHub Desktop.
Running JetBrains' InspectCode outputs an XML-file with references to the inspected files which are relative to the solution that was provided to the cli. When this XML-file is used with Jenkins' Warnings-plugin, the links to files (in the inspection-report) cannot be resolved, if the solution is not in the root of the workspace. This script pre…
param (
[string]$file = $(throw "-file is required."),
[string]$path = $(throw "-path is required.")
)
[System.IO.FileInfo]$fileInfo = $file
[xml]$xml = Get-Content -Path $file
foreach ($project in $xml.Report.Issues.Project) {
$projectName = $project.Name
write-output "Fixing @File attributes for project '$projectName'"
foreach ($issue in $project.Issue) {
$issue.File = $path + $issue.File
}
}
$xml.Save($file + ".fixed.xml")
@fguchelaar
Copy link
Author

Running JetBrains' InspectCode outputs an XML-file with references to the inspected files which are relative to the solution that was provided to the cli. When this XML-file is used with Jenkins' Warnings-plugin, the links to files (in the inspection-report) cannot be resolved, if the solution is not in the root of the workspace. This script prefixes all @File attributes with a provided argument.

Usage in Jenkins: InspectCodeFixPath.ps1 -file "$env:WORKSPACE/InspectCode.xml" -path "Compile/project/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment