Reputation: 1022
I am trying to automate a build process, but I am having issues with one of my script parameters.
I store the parameter and then substitute its value when I call svn checkout %repository%
on the command line.
Problem is it doesn't substitute and I get the following output:
PS C:\Users\Administrator\Desktop> .\Build_Script.bat "https://mitchellt/svn/Test_Repositry/Test_Application"
C:\Users\Administrator\Desktop>rem * Need to check directory exists
C:\Users\Administrator\Desktop>rem Variables
C:\Users\Administrator\Desktop>set date=13_10_2013
C:\Users\Administrator\Desktop>set time=16-56-48
C:\Users\Administrator\Desktop>set repository = https://mitchellt/svn/Test_Repositry/Test_Application
C:\Users\Administrator\Desktop>rem Change to build directory
C:\Users\Administrator\Desktop>cd C:\Build
C:\Build>rem Make Directory for Build based on today's date
C:\Build>mkdir 13_10_2013_16-56-48
C:\Build>rem Change to new directory
C:\Build>cd 13_10_2013_16-56-48
C:\Build\13_10_2013_16-56-48>rem Create folders for the source code, built product & test results
C:\Build\13_10_2013_16-56-48>mkdir Source
C:\Build\13_10_2013_16-56-48>mkdir Product
C:\Build\13_10_2013_16-56-48>mkdir Results
C:\Build\13_10_2013_16-56-48>rem Change to source directory
C:\Build\13_10_2013_16-56-48>cd Source
C:\Build\13_10_2013_16-56-48\Source>rem Copy the source code from the repository
C:\Build\13_10_2013_16-56-48\Source>svn checkout
svn: E205001: Try 'svn help checkout' for more information
svn: E205001: Not enough arguments provided
PS C:\Users\Administrator\Desktop>
CODE:
@ECHO ON
@SETLOCAL
rem * Need to check directory exists
rem Variables
set date=%DATE:/=_%
set time=%time:~0,2%-%time:~3,2%-%time:~6,2%
set repository = %1
rem Change to build directory
cd C:\Build
rem Make Directory for Build based on today's date
mkdir %date%_%time%
rem Change to new directory
cd %date%_%time%
rem Create folders for the source code, built product & test results
mkdir Source
mkdir Product
mkdir Results
rem Change to source directory
cd Source
rem Copy the source code from the repository
svn checkout %repository%
Upvotes: 2
Views: 1124
Reputation: 82337
The problem are the spaces at set repository = %1
and batch files are space sensitive (only sometimes at some points).
This creates a variable with the name repository<space>
Simply change it to
set repository=%1
Or better
set "repository=%~1"
As this also prevents problems with appended, invisble spaces after the %1
Upvotes: 5