0

My csv file looks like this

Product_Name    Component           SvnDirectory
ABC             export-service      export
ABC             import-service      import
ABC             service-service     service

My script should read this file and extract SvnDirectory column and store its values(export, import,service)in an array. I will later be using this to checkout from svn.

The script is

$svnDirectory= Import-Csv C:\temp\checkoutdirs.csv | % {$_.SvnDirectory}
Write-host $svnDirectory

The problem with this is, it stores values in such a way that I am not able to use it to checkout from svn.

Output
@Write-host $svnDirectory
export    import    service

So when I try to checkout using this

ForEach ($i in $svnDirectory) {
    $checkoutUrl = "$svnRepositoryBase/$svnDirectory/trunk"
    Write-host "SVN url to be checked out is $checkoutUrl"
    java -classpath $env:CLASSPATH org.tmatesoft.svn.cli.SVN co $checkoutUrl --username $username --password $securePassword --non-interactive
}

The svn url it takes is

SVN url to be checked out is 
http://subversion.abc.com/dev/prj/export  import  service/trunk
4
  • I tried this and I get only the svnsubdirectory in the array $projectName = import-csv ABC_Projects.csv | % {$_.SvnDirectory} Write-host $projectName Commented Apr 21, 2015 at 22:14
  • why do you delete your answer ? Commented Apr 22, 2015 at 3:33
  • Your loop is foreach ($i in $svnDirectory), but you're using $svnDirectory instead of $i to compose $checkoutUrl . Commented Apr 22, 2015 at 7:34
  • Silly me. Thanks for catching that. That fixed the issue. Commented Apr 22, 2015 at 16:02

1 Answer 1

3

Alright i tried this and it worked

 $projectName = import-csv  ABC_Projects.csv | % {$_.SvnDirectory}
 Write-host $projectName
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.