I have a batch file that first checks an outside file to see the source branch for the build then runs an if else if statement that runs regex to match the source branch which then determines where the build will deploy:
@echo off
setlocal enabledelayedexpansion
set SEPARATOR=/
set filecontent=
for /f "usebackqdelims=" %%a in ("BuildBranch.txt") do (
set currentline=%%a
set filecontent=!filecontent!%SEPARATOR%!currentline!
)
echo %filecontent%
If NOT "%filecontent%"=="develop(.*)" (
echo Deploying to dev DEVELOP
) else If NOT "%filecontent%"=="^.feature(.*)" (
echo Deploying to dev FEATURE
) else If NOT "%filecontent%"=="master(.*)" (
echo Deploying to integration MASTER
) else If NOT "%filecontent%"=="^.hotfix(.*)" (
echo Deploying to integration HOTFIX
)
pause
I have run each of the regex's through the regex101 site but there may still be issues with them. My main issue is that ever time I run my batch file it only runs the first of the If statements. The variable %filecontent% is feature/MyNewFeature so it should see that it doesn't match the first if statement and go on to the second statement. I don't know if this is an issue with my regex or my if statements.
if /?to get help)