The code in the question seems to be a mix of cmd and PowerShell, both with invalid syntax for either language. The first line appears to remove everything before the first SOLIDUS (forward slash) character in the GIT_BRANCH variable.
What happens with this?
SET "branch=%GIT_BRANCH:*/ =%"
if "%branch%" == "test" (ECHO Branch test)
if ("%branch%" == "master") (
MKDIR "C:JenkinsworkspaceApiApi_DEVAPI_Build_Master_TestMaster"
) else (
MKDIR "C:JenkinsworkspaceApiApi_DEVAPI_Build_Master_TestVarious"
)
UPDATE:
SET "branch=%GIT_BRANCH:*/ =%"
if "%branch%" == "test" (ECHO Branch test)
ECHO branch is set to ===%branch%===
SET "BUILD_ROOT=C:JenkinsworkspaceApiApi_DEVAPI_Build_Master_Test"
if ("%branch%" == "master") (
IF NOT EXIST "%BUILD_ROOT%Master" (MKDIR "%BUILD_ROOT%Master")
) else (
IF NOT EXIST "%BUILD_ROOT%Various" (MKDIR "%BUILD_ROOT%Various")
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…