1

I would like to use Jenkins multibranch pipeline with Subversion. The job is configured to include branches branches/* Consequently, for each branch (foo), it creates a folder named branches%2Ffoo corresponding to a branch-dedicated-job.

So far so good. It's not pretty but not blocking.

The branch-job then builds a MSVC project inside its folder. This MSVC projects defines a custom build step using the variable $(ProjectDir) in the command, which is resolved by something like C:\my\path\branches%2Ffoo\.

bat "CALL \"%VS120COMNTOOLS%VsDevCmd.bat\" && msbuild.exe /m \"toto.sln\" /target:build /property:Configuration=Debug"

And here is the blocking error: CALL or even DIR of this path fails with the error

The system cannot find the file specified.

Typing the same command from the console command works fine. It's only in MSVC custom build step that it doesn't work.

Does anyone knows how to work-around either the creation of folders with percent by Jenkins multibranch pipeline, or the support of percent in MSVC build ?

zerocukor287
  • 555
  • 2
  • 8
  • 23
A. Richard
  • 240
  • 1
  • 6
  • 1
    Are you aware the character representation of "%2f" is "/", which is the Unix file path separator? My guess is something sanitized a URL and now windows doesn't know what to do w/it. [Reported before](https://stackoverflow.com/questions/56114392/problem-with-multibranch-pipeline-jobs-with-branches-that-have-a-slash-in-their), maybe dig deeper to eliminate path conversion issue - or run on Linux! [JENKINS-34564](https://issues.jenkins.io/browse/JENKINS-34564) – Ian W Nov 24 '21 at 11:40
  • Please add a sample of the pipeline code to the question. – zett42 Nov 24 '21 at 13:12
  • @zett42 the pipeline code could be stripped down to a single step `bat "CALL \"%VS120COMNTOOLS%VsDevCmd.bat\" && msbuild.exe /m \"toto.sln\" /target:build /property:Configuration=Debug"` – A. Richard Nov 29 '21 at 08:36
  • @IanW thx for the pointers. It shows that many people have the issue, but I can't figure out in any thread how people have finally work-around it. – A. Richard Nov 29 '21 at 08:39
  • I don't use SVN or MSVC, so can't provide further guidance. Is everything hosted on Win? – Ian W Nov 29 '21 at 11:11

1 Answers1

0

To overcome the %2F in the path, we use a custom folder name made from the branch name.

First, get the BRANCH_NAME, and replace everything that is not an alphanumeric character.
Later, use this folder instead of the default workspace.

In the Jenkins file:

buildFolder = java.net.URLDecoder.decode(BRANCH_NAME, "UTF-8");

// Replace nasty chars
buildFolder = buildFolder.replaceAll("[^a-zA-Z0-9]", "_");

pipeline {
    agent {
        node {
            label 'my_project'
            customWorkspace "W:\\workdir\\${buildFolder}"
        }
    }
    ...
}

In the unix pipelines, for the customWorkspace we use something like /var/lib/jenkins/workspace/${buildFolder}

zerocukor287
  • 555
  • 2
  • 8
  • 23