Ant: scp create directory if not exist

前端 未结 2 1958
猫巷女王i
猫巷女王i 2021-01-21 18:17

I am using this to copy from A to B. But if for example the folder /config doesnt exist it gives me an exception. How can I solve it? I tried mkdirs=\"true\" but it runs to erro

2条回答
  •  滥情空心
    2021-01-21 19:08

    It's not possible to create remote directories with scp task. Here's a macrodef for scptransfer, that does all the work needed for transfer from a given stagedirectory => fix linefeeds, createremote, deleteremote, fail if stagedir empty ... etc. Macrodef is using ant addon Flaka, if you don't need all that bells and whistles, simply use sshexec task with mkdir -p before scp to create your remote targetdir.

    
    
    
    
    
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    
     
       
       =============== SCP Transfer ===============
        Project          = ${project}
        Environment      = ${env}
    
        UserID           = @{userid}
        Targetserver     = @{host}
        Targetpath       = @{remotedir}
        fixLF ?          = @{fixLF}
        createremote ?   = @{createremote}
        deleteremote ?   = @{deleteremote}
        #{@{deleteremote} ? 'deleteincludes   = @{deletecincludes}' : '' }
        Stagedir         = @{stagedir}
        stageincludes    = @{stageincludes}
        stageexcludes    = @{stageexcludes}
       =============== SCP Transfer ===============
       
       
       
        
       
         
           
             
             
               
             
             
             
               
               
                 
               
               
               
                 
               
               
               
                 
               
             
             
           
           
             
             =============== SCP Transfer =============
                   Skip => NO StageDirContents !!
             =============== SCP Transfer =============
             
             
           
         
     
    
    
     
    

    As we switched to Github only recently get the manual here and some examples here.

提交回复
热议问题