Reputation: 236
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 ?
Upvotes: 1
Views: 654
Reputation: 1073
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}
Upvotes: 0