When I try to msbuild a Multi-Branch Project in Jenkins, the build fails because msbuild replace the escape "%2F" with "\"
Example error:
"C:\Program Files (x86)\Jenkins\jobs\ProjectBranches\branches\branches%2FBranch-229\workspace\project\project\project.csproj" (default target) (1) -> C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.CSharp.CurrentVersion.targets(321,5): error MSB4019: The imported project "C:\Program Files (x86)\Jenkins\jobs\ProjectBranches\branches\branches\Branch-229\workspace\project\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.CSharp.Core.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. [C:\Program Files (x86)\Jenkins\jobs\ProjectBranches\branches\branches%2FBranch-229\workspace\project\project\project.csproj]
There is a whole discussion about branch name encoding in Jira #34564.
A propsed work-around that works for me is to change workspace dir in Jenkinsfile:
node(agent) {
def workspace_orig = pwd()
def workspace_sane = workspace_orig.replaceAll("%", "_")
ws(workspace_sane) {
// ...
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With