Updating a web app via azure pipelines and FTP

Kev Martin 0 Reputation points
2025-05-02T21:21:21.6833333+00:00

Hello

When I update spicetheworld.com from within Visual Studio with these creds it all goes well

User's image

However when I try to update spicetheworld.com from a azure pipeline

Test 1

      - task: FtpUpload@2
        displayName: 'FTP Upload'
        inputs:
          credentialsOption: inputs
          serverUrl: 'ftp://ftp.spicetheworld.com'
          username: azure
          password: ##########
          rootDirectory: '$(build.artifactstagingdirectory)'
          remoteDirectory: '/'
          trustSSL: true
          clean: true
          preservePaths: true

I get User's image

Test 2

- task: FtpUpload@2
        displayName: 'FTP Upload'
        inputs:
          credentialsOption: inputs
          serverUrl: 'ftp://ftp.spicetheworld.com'
          username: azure
          password: ##########
          rootDirectory: '$(build.artifactstagingdirectory)'
          remoteDirectory: '/spicetheworld.com'
          trustSSL: true
          clean: true
          preservePaths: true

User's image

However instead of updating the folder /spicetheworld.com this has created a new folder structure /spicetheworld.com/spicetheworld.com/SpiceTheWorld and the visible site is not updated.

To confirm the FTP user is called azure and the root folder for this user is /spicetheworld.com

Any ideas on where I am going wrong please

Azure DevOps
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Harshitha Veeramalla 966 Reputation points Microsoft External Staff Moderator
    2025-05-05T10:14:29.23+00:00

    Hi Kev Martin,
    The issue seems to be with mapping of your rootDirectory.

    By default, '$(build.artifactstagingdirectory)' takes the application root directory.

    • Instead of root directory set the parent rootDirectory value to the exact folder path $(Build.ArtifactStagingDirectory)/SpiceTheWorld.

    As per this MSDoc, preserve path has to be set to false.

    • preservePaths: true will recreate the entire structure under the remote folder.

    So, to upload the files without any folders set the preservePaths to false.

    • Store the FTP Username and Password in variables section.

    {479CAFD2-3C2E-43B4-BBA6-2AB60FEF1229}

    Hope this helps.


    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions, please reply back.


  2. Kev Martin 0 Reputation points
    2025-05-06T13:33:55.2533333+00:00

    Thanks for the tip above, that helped and now I have a solution as below

    With these changes and changing the destination folder from spicetheworld.com to spicetheworld we now have a fully working soution.

          - task: FtpUpload@2
            displayName: 'FTP Upload'
            inputs:
              credentialsOption: inputs
              serverUrl: 'ftp://5.77.32.147'
              username: $(ftpUser)
              password: $(ftpPassword)
              rootDirectory: '$(build.artifactstagingdirectory)/spicetheworld'
              remoteDirectory: '/spicetheworld'
              trustSSL: true
              clean: true
              preservePaths: true
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.