Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to msbuild a Multi-Branch Project in jenkins?

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]

like image 202
Nuts Avatar asked Mar 02 '16 16:03

Nuts


1 Answers

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) {
        // ...
    }

}
like image 58
qbik Avatar answered Oct 11 '22 02:10

qbik