NewinDevelopment
NewinDevelopment

Reputation: 1

Is it possible to download files/data during the build pipeline on Azure DevOps?

We would like to transfer the development via azure devops to another company and we ask ourselves whether not only new releases can be pushed through this pipeline. But also data could be downloaded from the productive environment via the azure devops or aws devops pipeline? I researched myself but found nothing about it.

does any of you have more information on this?

Thank you

Upvotes: 0

Views: 1842

Answers (2)

Jane Ma-MSFT
Jane Ma-MSFT

Reputation: 5242

Is it possible to download files/data during the build pipeline on Azure DevOps?

In Azure DevOps, there isn't a task to download files/data, but you can use the PowerShell task to connect to FTP server and download files.

For detailed information, you can refer to this similar question.

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      #FTP Server Information - SET VARIABLES
      $ftp = "ftp://XXX.com/" 
      $user = 'UserName' 
      $pass = 'Password'
      $folder = 'FTP_Folder'
      $target = "C:\Folder\Folder1\"
      
      #SET CREDENTIALS
      $credentials = new-object System.Net.NetworkCredential($user, $pass)
      
      function Get-FtpDir ($url,$credentials) {
          $request = [Net.WebRequest]::Create($url)
          $request.Method = [System.Net.WebRequestMethods+FTP]::ListDirectory
          if ($credentials) { $request.Credentials = $credentials }
          $response = $request.GetResponse()
          $reader = New-Object IO.StreamReader $response.GetResponseStream() 
          while(-not $reader.EndOfStream) {
              $reader.ReadLine()
          }
          #$reader.ReadToEnd()
          $reader.Close()
          $response.Close()
      }
      
      #SET FOLDER PATH
      $folderPath= $ftp + "/" + $folder + "/"
      
      $files = Get-FTPDir -url $folderPath -credentials $credentials
      
      $files 
      
      $webclient = New-Object System.Net.WebClient 
      $webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass) 
      $counter = 0
      foreach ($file in ($files | where {$_ -like "*.txt"})){
          $source=$folderPath + $file  
          $destination = $target + $file 
          $webclient.DownloadFile($source, $target+$file)
      
          #PRINT FILE NAME AND COUNTER
          $counter++
          $counter
          $source
      }

Certificate comes from: PowerShell Connect to FTP server and get files.

Upvotes: 1

KargWare
KargWare

Reputation: 2193

You should use artifacts when it is inside your "environment".

Otherwise you can use the normal command line tools like git or curl and wget this depends on your build agent.

Upvotes: 0

Related Questions