How to msbuild multi-branch project in jenkins?

When I try to generate a Multi-Branch project in Jenkins, the build will fail because msbuild will replace escape "% 2F" with "\"

Error example:

"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: imported project "C: \ Program Files (x86) \ Jenkins \ jobs \ ProjectBranches \ branch \ branches \ Branch-229 \ workspace \ project \ packages \ Microsoft.Net.Compilers.1.0.0 \ tools \ Microsoft.CSharp.Core.targets "not found. Verify 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]

+6
source share
2 answers

In the Jira # 34564 section, there is a whole discussion about branch name encoding.

The repertoire that works for me is to change the workspace directory in the Jenkinsfile :

node(agent) { def workspace_orig = pwd() def workspace_sane = workspace_orig.replaceAll("%", "_") ws(workspace_sane) { // ... } } 
+1
source

I just ran into this problem today. I decided to solve by overriding the assembly and workspace folder in the server configuration

I set the Workspace Root Directory to c: / ws / $ {ITEM_FULL_NAME} / work and Build Root Directory to c: / ws / $ {ITEM_FULL_NAME} / builds

ITEM_FULL_NAME is the name of the job, and since the job name has "/" and not% 2F, this will cause the folder to look like c: \ ws \ project \ branch \ name \ work, This should solve your problem.

0
source

All Articles