How to upload file to an FTP Server from Azure?

Hello Everyone,

I am very new to Octopus Deploy so forgive me for my ignorance. I have an FTP server where I need to upload my Angular Website. The source repo is configured in Azure so at first, I tried deployment using Azure pipelines. My hosting provider is a cheap provider so they are not giving me a lot of options to configure hosting. They have told me that I can upload files using any FTP client that supports passive mode. I want to automate this deployment process, so I would like to use Octopus Deploy to upload files to FTP server. I have just signed up for free tier and created a Cloud instance. The issue I am facing now is that I cannot create a target since I only have the FTP information of the host. Another problem I am facing is that I am not sure which process step to use for my task? Can somone please guide me on how can I deploy my website to a remote FTP server from Azure?

Thanks in advance.

Hi syed_afraz_ali,

Thanks a lot for reaching out. I’m here to work with you until you’re up and running and to answer any you questions you have.

We have a Step Template that you will be able to utilize in your project, which is fairly straightforward and allows you to upload information to your hosts FTP Server.

I don’t have all your hosts details, so I can’t test it out myself, but that step will be the best place to start. After you create a project and when you are adding a step - just type in “ftp” in the search box and you should see the Step Template I am talking about.

The great news is, because you are using Octopus Cloud, you will be able to set the Execution location to “Run once on a Worker”. If you choose the “Default Worker pool”, you won’t need to create a target as one will be dynamically allocated to run the script. You can just fill in the FTP details within the script step itself and deploy.

upload ftp

If you need to check or make some slight modification to the way the code works, you can click on the blue text Upload files by FTP from the image above and see exactly how the script works.

I hope this helps! Let me know how you go and please reach out if you need any more help.

Regards,

Dane

Hello Dane,
Thank you for your help! I was able to make some progress. I was able to upload package from Azure to my Octopus cloud instance. I can see it under library tab. Next, I created a step to upload file to FTP server like you mentioned and tried to create a release but got an error. Here is the log:

Leasing a dynamic worker

August 5th 2020 12:17:55

Info

Worker not ready, waiting 30s

August 5th 2020 12:18:25

Info

Obtained worker lease successfully.

August 5th 2020 12:18:25

Info

Leased worker 20-08-05-0141-jwu6h from pool Default Worker Pool (lease Leases-11858562).

August 5th 2020 12:18:26

Info

The version 13.0.10 of the Calamari.netfx tool has not been extracted, it will be extracted automatically.

August 5th 2020 12:18:44

Info

Version 13.0.10 of the Calamari.netfx tool has been extracted successfully

August 5th 2020 12:18:50

Error

OperationStopped: No value was set for Path to WinSCP .NET Assembly, and it cannot be empty

August 5th 2020 12:18:50

Error

At C:\Octopus\Tentacle\Work\20200805021845-228-5\Script.ps1:26 char:9

August 5th 2020 12:18:50

Error

  • throw "No value was set for $parameterName, and it cannot be …

August 5th 2020 12:18:50

Error

  • 
    

August 5th 2020 12:18:50

Error

at Validate-Parameter, C:\Octopus\Tentacle\Work\20200805021845-228-5\Script.ps1: line 26

August 5th 2020 12:18:50

Error

at , C:\Octopus\Tentacle\Work\20200805021845-228-5\Script.ps1: line 126

August 5th 2020 12:18:50

Error

at , C:\Octopus\Tentacle\Work\20200805021845-228-5\Bootstrap.Script.ps1: line 1679

August 5th 2020 12:18:50

Error

at , : line 1

August 5th 2020 12:18:50

Error

at , : line 1

August 5th 2020 12:18:50

Fatal

The remote script failed with exit code 1

August 5th 2020 12:18:50

Fatal

The action FTP Upload on a Worker failed

Can you please tell me how to install the Winscp assembly on my cloud instance?

Secondly I have a question. How is this step able to figure out which package to deploy? It seems like there is no relation between this step and the package that I have uploaded. What if I want to deploy a specific version of package from library tab?

Thanks
Afraz

Hi Afraz,

Great news that you are progressing!

Can you please tell me how to install the Winscp assembly on my cloud instance?

If you create a step within your project - “Run a Script”. I’ve quickly put together a Powershell script that will install WinSCP (you can specify whatever version you require). It also provides the location of the installed module.

Install-Module -Name WinSCP -RequiredVersion 5.13.7.0 -Force
Import-Module WinSCP
$env:PSModulePath
Get-Module -Name "WinSCP" #Proof that it installed
Get-ChildItem -Path "C:\Program Files\WindowsPowerShell\Modules" | Where-object {$_.Name -eq "WinSCP"}

You will have to put together a couple of checks and balances but hopefully the script will get you started.

Secondly I have a question. How is this step able to figure out which package to deploy? It seems like there is no relation between this step and the package that I have uploaded.

This is a community supplied step template. The script that runs is available to view by clicking on the Upload files by FTP link. The picture I attached to my last reply shows the link and this is the best way to understand the inner workings of a step template.

Looking into the script - It looks for a step with the name provided in “Package Step Name”. Once it finds that step, it will attempt to determine the variable “InstallationDirectoryPath” or more precisely: “Octopus.Action[$stepName].Output.Package.InstallationDirectoryPath”.

If you aren’t familiar with variables within Octopus and their usage, start by having a read through this part of our documentation: https://octopus.com/docs/projects/variables

What if I want to deploy a specific version of package from library tab?

This will most likely require some modification to the script. This link here should provide all the information you need to get started, on referencing packages from within a script: https://octopus.com/blog/script-step-packages

Feel free to reach out if you hit any more bottle-necks or problems.

Regards,

Dane

Hi Dane,

Thank you for providing more context. Unfortunately, I am still struggling to get my first deployment done :frowning:

I have added a step to install WInSCP. However, the documentation of Upload FTP Files step states that before this step I need to add “Deploy a Package” step. Which makes sense because like I mentioned above, it was confusing which package will be deployed by this step?

Now the problem is that if I try to add a “Deploy a Package” step, it asks me to select a role, but in my case, there is no role defined. Sorry for being a total newbie but I am struggling to understand how I can make it work. Can you please show me a working example of steps that should upload files to an FTP server?

Thanks,
Afraz

Hi Syed,

I understand completely that Octopus can be a bit daunting at first. I would highly recommend taking a step back to get a simple Deployment working. We have a “Hello World” series available here:

This will give you the building blocks and understanding of a lot of the terms and theory around how to deploy, using Roles, Projects and Environments. This will save you time in the future, when you start working on more advanced deployments. You can also find some good information on other concepts within the documentation, especially if video tutorials are not for you. Here’s a page on the concept of Roles: https://octopus.com/docs/getting-started/octopus-concepts/target-roles

You have indeed pointed out a flaw in the “Upload FTP Files” step template. The fact that the step template cannot deploy a package without it being deployed to a target first is not ideal. The Step template was created before the introduction of the worker concept, which is why it is the way that it is, so it could use an update. We usually leave it up to the community to improve the community step templates. If you want to make changes to the step template, feel free to submit a pull request with the updated code.

If you chose to use this community step, you would need to deploy to a target first. In order to do that, you would need to create a deployment target first.

Pre Step 1: Create a Deployment Target: https://octopus.com/docs/infrastructure/deployment-targets
Step 1: Deploy a Package:
Step 2: Upload Files by FTP

Within the Upload Files by FTP step - you would reference the package from step 1. If you are unsure on how to do this, please check the link at the bottom of this reply (referencing packages).

If we were to ignore the community step, you could use powershell (or whatever language you are familiar with that is supported by Octopus) and deploy via a worker, by running this script:

# create the FtpWebRequest and configure it
$ftp = [System.Net.FtpWebRequest]::Create("ftp://ftphost")
$ftp = [System.Net.FtpWebRequest]$ftp
$ftp.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile
$ftp.Credentials = new-object System.Net.NetworkCredential("anonymous","anonymous@localhost")
$ftp.UseBinary = $true
$ftp.UsePassive = $true
# read in the file to upload as a byte array
$Package = $OctopusParameters["Octopus.Action.Package[NugetTesting.Package].PackageFilePath"]
$content = [System.IO.File]::ReadAllBytes("$Package")
$ftp.ContentLength = $content.Length
# get the request stream, and write the bytes into it
$rs = $ftp.GetRequestStream()
$rs.Write($content, 0, $content.Length)
# be sure to clean up after ourselves
$rs.Close()
$rs.Dispose()

So to be clear - you would only need one step, which would be a “Deploy a Script”.

You would also need to reference the package within the same script step:

If you are unsure of how I determined the package variable to use in the Powershell script, please refer to this guide: https://octopus.com/docs/deployment-examples/custom-scripts/run-a-script-step#referencing-packages.

This is probably as close to a working example as I can provide for you, without knowing the ftp service you are using and it’s capabilities.

Hopefully this helps!

Regards,

Dane

Hi Afraz,

I thought I would provide another update on this one.

One of the Engineering team had a little bit of spare time and gave that community step a spit and polish.

The step has been updated to be able to choose a package from the package store. The PR will still need to be reviewed and then updated - so this may take a day or two, however it is on it’s way.

Thanks for helping to shape Octopus!

Regards,

Dane

Hi Dane,

That’s wonderful! I will definetly give it another shot once the PR is merged to the community step.

I am studying more about Octopus meanwhile and also went through the links that you shared but I think my case is that there are not much options for a uploading to FTP directory. For example you mentioned that I should create a deployment target. I don’t think you can create a deployment target for a FTP directory in Octopus, or maybe I missed something. That is the reason I went for this approach.

A custom script to upload files on the FTP server via PS seems a good option but then I could have done the same thing from the Azure release pipeline. I know Octopus is much more powerful in so many aspects but I was thinking that since uploading files via FTP is a common task, it will be really easy to implement in Octopus. Azure seems to lack this functionality as well!

Having said that, I will definitely give it a try once the community step is updated. I am learning a lot too due to this exercise :slight_smile:

Hi Dane,

Sorry for the late reply. I was busy and couldn’t work on this project. I have made some progress. I have changed my steps to use ‘Upload files by FTP from package’ step. I believe this is the new step that got published. I am using a variable in my pipeline to set path of WinScp and I think that is causing an issue now.

My variable is pointing to this location: C:\Program Files\WindowsPowerShell\Modules\WinSCP\5.13.7.0\bin

When I am running my release, I am getting the following error:

August 20th 2020 10:34:09

Error

OperationStopped: The winscp.exe executable was not found at location of the assembly (C:\Program Files\WindowsPowerShell\Modules\WinSCP\5.13.7.0\bin), nor in an installation path. You may use Session.ExecutablePath property to explicitly set path to winscp.exe.

August 20th 2020 10:34:09

Error

At C:\Octopus\Tentacle\Work\20200820003341-734-8\Script.ps1:323 char:5

August 20th 2020 10:34:09

Error

  • throw $_.Exception.Message

August 20th 2020 10:34:09

Error

  • 
    

August 20th 2020 10:34:09

Error

at , C:\Octopus\Tentacle\Work\20200820003341-734-8\Script.ps1: line 323

August 20th 2020 10:34:09

Error

at , C:\Octopus\Tentacle\Work\20200820003341-734-8\Bootstrap.Script.ps1: line 2154

August 20th 2020 10:34:09

Error

at , : line 1

August 20th 2020 10:34:09

Error

at , : line 1

August 20th 2020 10:34:09

Fatal

The remote script failed with exit code 1

August 20th 2020 10:34:09

Fatal

The action Upload Files By FTP From Package on a Worker failed

Can you please guide me on what path to set for WinScp? I couldn’t find a lot of help on forum.

Thanks

If you leave the path to WinSCP blank, it will download the PowerShell module and use that instead. Are you willing to give that a go?

I reviewed the code, it looks like it should find it there. It looks like you have the WinSCP PowerShell module installed already, if you leave the path entry blank, it should load up this module and continue.

Hi Shawn,

I have set the path value to blank. Now I am getting the following error:

August 20th 2020 11:50:07

Error

OperationStopped: Cannot find type [WinSCP.SessionOptions]: verify that the assembly containing this type is loaded.

August 20th 2020 11:50:07

Error

At C:\Octopus\Tentacle\Work\20200820014943-742-22\Script.ps1:323 char:5

August 20th 2020 11:50:07

Error

  • throw $_.Exception.Message

August 20th 2020 11:50:07

Error

  • 
    

August 20th 2020 11:50:07

Error

at , C:\Octopus\Tentacle\Work\20200820014943-742-22\Script.ps1: line 323

August 20th 2020 11:50:07

Error

at , C:\Octopus\Tentacle\Work\20200820014943-742-22\Bootstrap.Script.ps1: line 2163

August 20th 2020 11:50:07

Error

at , : line 1

August 20th 2020 11:50:07

Error

at , : line 1

August 20th 2020 11:50:08

Fatal

The remote script failed with exit code 1

August 20th 2020 11:50:08

Fatal

The action Upload Files By FTP From Package on a Worker failed

Can you provide the entire log file?

Sure mate, its attached below:

Task ID: ServerTasks-742
Related IDs: Deployments-28, Channels-1, Releases-28, Projects-1, Spaces-1, Environments-1
Task status: Failed
Task queued: Thursday, 20 August 2020 1:47:57 AM +00:00
Task started: Thursday, 20 August 2020 1:47:57 AM +00:00
Task completed: Thursday, 20 August 2020 1:50:09 AM +00:00
Task duration: 2 minutes
Server version: 2020.3.3+Branch.tags-2020.3.3.Sha.dcb8c7449b4a13fecfcbcb9ca49d3147d434eb12
Server node: octopus-i015781-897ff49fb-9qjlg

                | == Failed: Deploy Educanist release 0.0.16 to Development ==

01:47:57 Info | Step 2: See files is disabled, and will not be executed
01:47:57 Info | Step 3: FTP Upload is disabled, and will not be executed
01:47:58 Verbose | Guided failure is not enabled for this task
01:50:09 Verbose | Releasing workers that required packages.
01:50:09 Verbose | Successfully called release for dynamic pool lease Leases-12831799 : 20-08-19-2328-5b4zc
01:50:09 Fatal | The deployment failed because one or more steps failed. Please see the deployment log for details.
|
| == Success: Step 1: Install WinSCP ==
01:49:39 Verbose | Install WinSCP completed
|
| == Success: Worker ==
01:47:58 Verbose | Octopus Server version: 2020.3.3+Branch.tags-2020.3.3.Sha.dcb8c7449b4a13fecfcbcb9ca49d3147d434eb12
01:47:58 Verbose | Environment Information:
| IsRunningInContainer: True
| OperatingSystem: Linux 4.15.0-1089-azure #99~16.04.1-Ubuntu SMP Fri Jun 5 15:30:32 UTC 2020
| OsBitVersion: x64
| Is64BitProcess: True
| CurrentUser: root
| MachineName: octopus-i015781-897ff49fb-9qjlg
| ProcessorCount: 2
| CurrentDirectory: /Octopus
| TempDirectory: /tmp/
| HostProcessName: Octopus.Server
| PID: 1
01:47:58 Info | Leasing a dynamic worker of type WindowsDefault…
01:47:58 Info | Obtained worker lease successfully.
01:47:58 Verbose | Leased worker 20-08-19-2328-5b4zc from pool Default Worker Pool (lease Leases-12831239).
01:47:58 Verbose | Executing Install WinSCP (type Run a Script) on DynamicWorker 20-08-19-2328-5b4zc
01:47:58 Verbose | Using Calamari.netfx 13.0.10
01:47:58 Verbose | Using Calamari.linux-x64 13.0.10
01:49:00 Verbose | Starting C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in working directory ‘C:\Octopus\Tentacle\Work\20200820014900-742-20’ using ‘OEM United States’ encoding running as ‘NT AUTHORITY\SYSTEM’ with the same environment variables as the launching process
01:49:01 Verbose | Calamari Version: 13.0.10
01:49:01 Verbose | Environment Information:
01:49:01 Verbose | OperatingSystem: Microsoft Windows NT 10.0.14393.0
01:49:01 Verbose | OsBitVersion: x64
01:49:01 Verbose | Is64BitProcess: True
01:49:01 Verbose | CurrentUser: NT AUTHORITY\SYSTEM
01:49:01 Verbose | MachineName: pkrvmtrqonemf4x
01:49:01 Verbose | ProcessorCount: 2
01:49:01 Verbose | CurrentDirectory: C:\Octopus\Tentacle\Work\20200820014900-742-20
01:49:01 Verbose | TempDirectory: C:\windows\TEMP
01:49:01 Verbose | HostProcess: Calamari (1060)
01:49:02 Verbose | Performing variable substitution on ‘C:\Octopus\Tentacle\Work\20200820014900-742-20\Script.ps1’
01:49:02 Verbose | Executing ‘C:\Octopus\Tentacle\Work\20200820014900-742-20\Script.ps1’
01:49:02 Verbose | Setting Proxy Environment Variables
01:49:03 Verbose | Name Value
01:49:03 Verbose | ---- -----
01:49:03 Verbose | PSVersion 5.1.14393.3866
01:49:03 Verbose | PSEdition Desktop
01:49:03 Verbose | PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
01:49:03 Verbose | BuildVersion 10.0.14393.3866
01:49:03 Verbose | CLRVersion 4.0.30319.42000
01:49:03 Verbose | WSManStackVersion 3.0
01:49:03 Verbose | PSRemotingProtocolVersion 2.3
01:49:03 Verbose | SerializationVersion 1.1.0.1
01:49:04 Verbose | PowerShell Environment Information:
01:49:04 Verbose | OperatingSystem: Microsoft Windows NT 10.0.14393.0
01:49:04 Verbose | OsBitVersion: x64
01:49:04 Verbose | Is64BitProcess: True
01:49:04 Verbose | CurrentUser: NT AUTHORITY\SYSTEM
01:49:04 Verbose | MachineName: pkrvmtrqonemf4x
01:49:04 Verbose | ProcessorCount: 2
01:49:04 Verbose | CurrentDirectory: C:\Octopus\Tentacle\Work\20200820014900-742-20
01:49:04 Verbose | CurrentLocation: C:\Octopus\Tentacle\Work\20200820014900-742-20
01:49:04 Verbose | TempDirectory: C:\windows\TEMP
01:49:04 Verbose | HostProcess: powershell (2472)
01:49:04 Verbose | TotalPhysicalMemory: 4193844 KB
01:49:04 Verbose | AvailablePhysicalMemory: 3364904 KB
01:49:34 Info | C:\windows\system32\config\systemprofile\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\windows\system32\WindowsPowerShell\v1.0\Modules
01:49:34 Info | ModuleType Version Name ExportedCommands
01:49:34 Info | ---------- ------- ---- ----------------
01:49:34 Info | Script 5.13.7.0 WinSCP {ConvertTo-WinSCPE…
01:49:34 Info | PSPath : Microsoft.PowerShell.Core\FileSystem::C:\Program
01:49:34 Info | Files\WindowsPowerShell\Modules\WinSCP
01:49:34 Info | PSParentPath : Microsoft.PowerShell.Core\FileSystem::C:\Program
01:49:34 Info | Files\WindowsPowerShell\Modules
01:49:34 Info | PSChildName : WinSCP
01:49:34 Info | PSDrive : C
01:49:34 Info | PSProvider : Microsoft.PowerShell.Core\FileSystem
01:49:34 Info | PSIsContainer : True
01:49:34 Info | Name : WinSCP
01:49:34 Info | FullName : C:\Program Files\WindowsPowerShell\Modules\WinSCP
01:49:34 Info | Parent : Modules
01:49:34 Info | Exists : True
01:49:34 Info | Root : C:
01:49:34 Info | Extension :
01:49:34 Info | CreationTime : 8/20/2020 12:33:26 AM
01:49:34 Info | CreationTimeUtc : 8/20/2020 12:33:26 AM
01:49:34 Info | LastAccessTime : 8/20/2020 1:49:30 AM
01:49:34 Info | LastAccessTimeUtc : 8/20/2020 1:49:30 AM
01:49:34 Info | LastWriteTime : 8/20/2020 1:49:30 AM
01:49:34 Info | LastWriteTimeUtc : 8/20/2020 1:49:30 AM
01:49:34 Info | Attributes : Directory
01:49:34 Info | Mode : d-----
01:49:34 Info | BaseName : WinSCP
01:49:34 Info | Target : {}
01:49:34 Info | LinkType :
01:49:38 Info | C:\Program Files\WindowsPowerShell\Modules\WinSCP\5.13.7.0
01:49:38 Verbose | Process C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\Octopus\Tentacle\Work\20200820014900-742-20 exited with code 0
01:49:38 Verbose | Updating manifest with output variables
01:49:38 Verbose | Updating manifest with action evaluated variables
01:49:39 Verbose | Successfully called release for dynamic pool lease Leases-12831239 : 20-08-19-2328-5b4zc
01:49:39 Verbose | Successfully finished Install WinSCP on a Worker
|
| == Success: Acquire packages ==
01:49:39 Info | Acquiring packages
01:49:39 Info | Making a list of packages to acquire
01:49:39 Info | Leasing a dynamic worker of type WindowsDefault…
01:49:40 Info | Obtained worker lease successfully.
01:49:40 Verbose | Leased worker 20-08-19-2328-5b4zc from pool Default Worker Pool (lease Leases-12831799).
01:49:40 Verbose | Package Educanist v267 is required by action ‘Upload Files By FTP From Package’
01:49:40 Verbose | No packages are required on the Octopus Server
01:49:40 Verbose | Delta compression is enabled for package transfers from the Octopus Server to deployment targets
01:49:40 Verbose | Machine DynamicWorker 20-08-19-2328-5b4zc still needs packages Educanist v267 for action (‘Upload Files By FTP From Package’)
01:49:42 Info | All packages have been acquired
01:49:42 Verbose | Acquire Packages completed
|
| Success: DynamicWorker 20-08-19-2328-5b4zc
|
| Success: Upload package Educanist v267
01:49:40 Verbose | Checking package cache for package Educanist v267
01:49:40 Info | Package Educanist v267 was found in cache. No need to download from feed.
01:49:40 Verbose | Using file: /repository/Spaces-1/feeds-builtin/Educanist/Educanist.267.nupkg
01:49:40 Verbose | Using Calamari.netfx 13.0.10
01:49:40 Verbose | Using Calamari.linux-x64 13.0.10
01:49:40 Verbose | Starting C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in working directory ‘C:\Octopus\Tentacle\Work\20200820014940-742-21’ using ‘OEM United States’ encoding running as ‘NT AUTHORITY\SYSTEM’ with the same environment variables as the launching process
01:49:41 Verbose | Calamari Version: 13.0.10
01:49:41 Verbose | Environment Information:
01:49:41 Verbose | OperatingSystem: Microsoft Windows NT 10.0.14393.0
01:49:41 Verbose | OsBitVersion: x64
01:49:41 Verbose | Is64BitProcess: True
01:49:41 Verbose | CurrentUser: NT AUTHORITY\SYSTEM
01:49:41 Verbose | MachineName: pkrvmtrqonemf4x
01:49:41 Verbose | ProcessorCount: 2
01:49:41 Verbose | CurrentDirectory: C:\Octopus\Tentacle\Work\20200820014940-742-21
01:49:41 Verbose | TempDirectory: C:\windows\TEMP
01:49:41 Verbose | HostProcess: Calamari (640)
01:49:42 Verbose | Package Educanist 267 hash 0534438341b17dab7107f3b7b9673c425232bd1c has already been uploaded
01:49:42 Verbose | Process C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\Octopus\Tentacle\Work\20200820014940-742-21 exited with code 0
01:49:42 Verbose | Exit code: 0
01:49:42 Info | Package Educanist version 267 found in cache. No need to upload this 39.304 MB package. Using C:\Octopus\Tentacle\Files\Educanist@S267@33DBCD58A4F40E478393024B0685C413.nupkg
|
| == Failed: Step 4: Upload Files By FTP From Package ==
01:50:08 Fatal | The step failed: Activity Upload Files By FTP From Package on a Worker failed with error ‘The remote script failed with exit code 1’.
01:50:08 Verbose | Upload Files By FTP From Package completed
|
| == Failed: Worker ==
01:49:43 Verbose | Octopus Server version: 2020.3.3+Branch.tags-2020.3.3.Sha.dcb8c7449b4a13fecfcbcb9ca49d3147d434eb12
01:49:43 Verbose | Environment Information:
| IsRunningInContainer: True
| OperatingSystem: Linux 4.15.0-1089-azure #99~16.04.1-Ubuntu SMP Fri Jun 5 15:30:32 UTC 2020
| OsBitVersion: x64
| Is64BitProcess: True
| CurrentUser: root
| MachineName: octopus-i015781-897ff49fb-9qjlg
| ProcessorCount: 2
| CurrentDirectory: /Octopus
| TempDirectory: /tmp/
| HostProcessName: Octopus.Server
| PID: 1
01:49:43 Verbose | Executing Upload Files By FTP From Package (type Run a Script) on DynamicWorker 20-08-19-2328-5b4zc
01:49:43 Verbose | Using Calamari.netfx 13.0.10
01:49:43 Verbose | Using Calamari.linux-x64 13.0.10
01:49:43 Verbose | Starting C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in working directory ‘C:\Octopus\Tentacle\Work\20200820014943-742-22’ using ‘OEM United States’ encoding running as ‘NT AUTHORITY\SYSTEM’ with the same environment variables as the launching process
01:49:44 Verbose | Calamari Version: 13.0.10
01:49:44 Verbose | Environment Information:
01:49:44 Verbose | OperatingSystem: Microsoft Windows NT 10.0.14393.0
01:49:44 Verbose | OsBitVersion: x64
01:49:44 Verbose | Is64BitProcess: True
01:49:44 Verbose | CurrentUser: NT AUTHORITY\SYSTEM
01:49:44 Verbose | MachineName: pkrvmtrqonemf4x
01:49:44 Verbose | ProcessorCount: 2
01:49:44 Verbose | CurrentDirectory: C:\Octopus\Tentacle\Work\20200820014943-742-22
01:49:44 Verbose | TempDirectory: C:\windows\TEMP
01:49:44 Verbose | HostProcess: Calamari (2692)
01:49:45 Verbose | Considering ‘FtpPackage’ for extraction
01:49:45 Info | Extracting package ‘C:\Octopus\Tentacle\Files\Educanist@S267@33DBCD58A4F40E478393024B0685C413.nupkg’ to ‘C:\Octopus\Tentacle\Work\20200820014943-742-22\FtpPackage’
01:50:04 Verbose | Performing variable substitution on ‘C:\Octopus\Tentacle\Work\20200820014943-742-22\Script.ps1’
01:50:04 Verbose | Executing ‘C:\Octopus\Tentacle\Work\20200820014943-742-22\Script.ps1’
01:50:04 Verbose | Setting Proxy Environment Variables
01:50:07 Verbose | Name Value
01:50:07 Verbose | ---- -----
01:50:07 Verbose | PSVersion 5.1.14393.3866
01:50:07 Verbose | PSEdition Desktop
01:50:07 Verbose | PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
01:50:07 Verbose | BuildVersion 10.0.14393.3866
01:50:07 Verbose | CLRVersion 4.0.30319.42000
01:50:07 Verbose | WSManStackVersion 3.0
01:50:07 Verbose | PSRemotingProtocolVersion 2.3
01:50:07 Verbose | SerializationVersion 1.1.0.1
01:50:07 Verbose | PowerShell Environment Information:
01:50:07 Verbose | OperatingSystem: Microsoft Windows NT 10.0.14393.0
01:50:07 Verbose | OsBitVersion: x64
01:50:07 Verbose | Is64BitProcess: True
01:50:07 Verbose | CurrentUser: NT AUTHORITY\SYSTEM
01:50:07 Verbose | MachineName: pkrvmtrqonemf4x
01:50:07 Verbose | ProcessorCount: 2
01:50:07 Verbose | CurrentDirectory: C:\Octopus\Tentacle\Work\20200820014943-742-22
01:50:07 Verbose | CurrentLocation: C:\Octopus\Tentacle\Work\20200820014943-742-22
01:50:07 Verbose | TempDirectory: C:\windows\TEMP
01:50:07 Verbose | HostProcess: powershell (1716)
01:50:07 Verbose | TotalPhysicalMemory: 4193844 KB
01:50:07 Verbose | AvailablePhysicalMemory: 3317160 KB
01:50:07 Info | Package was installed to: C:\Octopus\Tentacle\Work\20200820014943-742-22\FtpPackage
01:50:07 Error | OperationStopped: Cannot find type [WinSCP.SessionOptions]: verify that the assembly containing this type is loaded.
01:50:07 Error | At C:\Octopus\Tentacle\Work\20200820014943-742-22\Script.ps1:323 char:5
01:50:07 Error | + throw $_.Exception.Message
01:50:07 Error | + ~~~~~~~~~~~~~~~~~~~~~~~~~~
01:50:07 Error | at , C:\Octopus\Tentacle\Work\20200820014943-742-22\Script.ps1: line 323
01:50:07 Error | at , C:\Octopus\Tentacle\Work\20200820014943-742-22\Bootstrap.Script.ps1: line 2163
01:50:07 Error | at , : line 1
01:50:07 Error | at , : line 1
01:50:07 Verbose | Adding journal entry:
01:50:07 Verbose |
01:50:07 Verbose |
01:50:07 Verbose |
01:50:08 Verbose | Process C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\Octopus\Tentacle\Work\20200820014943-742-22 exited with code 1
01:50:08 Verbose | Updating manifest with output variables
01:50:08 Verbose | Updating manifest with action evaluated variables
01:50:08 Fatal | The remote script failed with exit code 1
01:50:08 Fatal | The action Upload Files By FTP From Package on a Worker failed

Thank you for providing those logs (and reformatting them, I was going cross-eyed) :slight_smile: This shouldn’t matter, but if you’d be willing to try disabling the step that you use to install WinSCP on the worker and let the Step Template do it instead? I’m curious if there will be any difference in behavior.

Hi Shawn,

I have disabled that step and getting different error now. Here are the logs…

Just wanted to point out one thing, the hosting provider asked me to use passive mode for FTP upload. I am not sure if that might be causing this issue?
Although the error message does not seems to related.

Task ID: ServerTasks-748
Related IDs: Deployments-29, Channels-1, Releases-29, Projects-1, Spaces-1, Environments-1
Task status: Failed
Task queued: Thursday, 20 August 2020 5:20:49 AM +00:00
Task started: Thursday, 20 August 2020 5:20:50 AM +00:00
Task completed: Thursday, 20 August 2020 5:23:21 AM +00:00
Task duration: 3 minutes
Server version: 2020.3.3+Branch.tags-2020.3.3.Sha.dcb8c7449b4a13fecfcbcb9ca49d3147d434eb12
Server node: octopus-i015781-897ff49fb-9qjlg

                | == Failed: Deploy Educanist release 0.0.17 to Development ==

05:20:50 Info | Step 1: Install WinSCP is disabled, and will not be executed
05:20:50 Info | Step 2: See files is disabled, and will not be executed
05:20:50 Info | Step 3: FTP Upload is disabled, and will not be executed
05:20:50 Verbose | Guided failure is not enabled for this task
05:23:20 Verbose | Releasing workers that required packages.
05:23:20 Verbose | Successfully called release for dynamic pool lease Leases-12840841 : 20-08-20-0434-tdjqn
05:23:21 Fatal | The deployment failed because one or more steps failed. Please see the deployment log for details.
|
| == Success: Acquire packages ==
05:20:50 Info | Acquiring packages
05:20:50 Info | Making a list of packages to acquire
05:20:50 Info | Leasing a dynamic worker of type WindowsDefault…
05:20:50 Info | Worker not ready, waiting 20s
05:21:11 Info | Worker not ready, waiting 20s
05:21:31 Info | Obtained worker lease successfully.
05:21:31 Verbose | Leased worker 20-08-20-0434-tdjqn from pool Default Worker Pool (lease Leases-12840841).
05:21:31 Verbose | Package Educanist v267 is required by action ‘Upload Files By FTP From Package’
05:21:31 Verbose | No packages are required on the Octopus Server
05:21:31 Verbose | Delta compression is enabled for package transfers from the Octopus Server to deployment targets
05:21:31 Verbose | Machine DynamicWorker 20-08-20-0434-tdjqn still needs packages Educanist v267 for action (‘Upload Files By FTP From Package’)
05:21:53 Info | All packages have been acquired
05:21:53 Verbose | Acquire Packages completed
|
| Success: DynamicWorker 20-08-20-0434-tdjqn
|
| Success: Upload package Educanist v267
05:21:31 Verbose | Checking package cache for package Educanist v267
05:21:31 Info | Package Educanist v267 was found in cache. No need to download from feed.
05:21:31 Verbose | Using file: /repository/Spaces-1/feeds-builtin/Educanist/Educanist.267.nupkg
05:21:31 Verbose | Using Calamari.netfx 13.0.10
05:21:31 Verbose | Using Calamari.linux-x64 13.0.10
05:21:31 Verbose | Starting C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in working directory ‘C:\Octopus\Tentacle\Work\20200820052131-748-2’ using ‘OEM United States’ encoding running as ‘NT AUTHORITY\SYSTEM’ with the same environment variables as the launching process
05:21:32 Verbose | Process C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\Octopus\Tentacle\Work\20200820052131-748-2 exited with code 1
05:21:32 Verbose | Using Calamari.netfx 13.0.10
05:21:32 Info | The version 13.0.10 of the Calamari.netfx tool has not been extracted, it will be extracted automatically.
05:21:32 Verbose | Starting C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in working directory ‘C:\Octopus\Tentacle\Work\20200820052132-748-3’ using ‘OEM United States’ encoding running as ‘NT AUTHORITY\SYSTEM’ with the same environment variables as the launching process
05:21:33 Verbose | Process C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\Octopus\Tentacle\Work\20200820052132-748-3 exited with code 0
05:21:33 Verbose | Starting C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in working directory ‘C:\Octopus\Tentacle\Work\20200820052133-748-4’ using ‘OEM United States’ encoding running as ‘NT AUTHORITY\SYSTEM’ with the same environment variables as the launching process
05:21:34 Verbose | Checking for C:\Octopus\Tentacle\Tools\Calamari.netfx\13.0.10\Success.txt
05:21:35 Verbose | Package: C:\Octopus\Tentacle\Work\20200820052133-748-4\Calamari.netfx.13.0.10.nupkg
05:21:35 Verbose | Destination: C:\Octopus\Tentacle\Tools\Calamari.netfx\13.0.10
05:21:47 Verbose | 92 files extracted
05:21:47 Verbose | 13.0.10 extracted to C:\Octopus\Tentacle\Tools\Calamari.netfx\13.0.10
05:21:47 Verbose | Cleaning up old Calamari.netfx versions…
05:21:47 Verbose | Keeping only Calamari.netfx version 13.0.10…
05:21:47 Verbose | Found no old versions of Calamari.netfx to delete…
05:21:47 Verbose | Process C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\Octopus\Tentacle\Work\20200820052133-748-4 exited with code 0
05:21:47 Info | Version 13.0.10 of the Calamari.netfx tool has been extracted successfully
05:21:47 Verbose | Starting C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in working directory ‘C:\Octopus\Tentacle\Work\20200820052147-748-5’ using ‘OEM United States’ encoding running as ‘NT AUTHORITY\SYSTEM’ with the same environment variables as the launching process
05:21:48 Verbose | Calamari Version: 13.0.10
05:21:48 Verbose | Environment Information:
05:21:48 Verbose | OperatingSystem: Microsoft Windows NT 10.0.14393.0
05:21:48 Verbose | OsBitVersion: x64
05:21:48 Verbose | Is64BitProcess: True
05:21:48 Verbose | CurrentUser: NT AUTHORITY\SYSTEM
05:21:48 Verbose | MachineName: pkrvmtrqonemf4x
05:21:48 Verbose | ProcessorCount: 2
05:21:48 Verbose | CurrentDirectory: C:\Octopus\Tentacle\Work\20200820052147-748-5
05:21:48 Verbose | TempDirectory: C:\windows\TEMP
05:21:48 Verbose | HostProcess: Calamari (2672)
05:21:49 Verbose | Package Educanist version 267 hash 0534438341b17dab7107f3b7b9673c425232bd1c has not been uploaded.
05:21:49 Verbose | Finding earlier packages that have been uploaded to this Tentacle.
05:21:49 Verbose | No earlier packages for Educanist has been uploaded
05:21:49 Verbose | Found 0 earlier versions of Educanist on this Tentacle
05:21:49 Verbose | Process C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\Octopus\Tentacle\Work\20200820052147-748-5 exited with code 0
05:21:49 Verbose | Exit code: 0
05:21:49 Verbose | Using Calamari.netfx 13.0.10
05:21:49 Verbose | Using Calamari.linux-x64 13.0.10
05:21:49 Verbose | Starting C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in working directory ‘C:\Octopus\Tentacle\Work\20200820052149-748-6’ using ‘OEM United States’ encoding running as ‘NT AUTHORITY\SYSTEM’ with the same environment variables as the launching process
05:21:50 Verbose | Calamari Version: 13.0.10
05:21:50 Verbose | Environment Information:
05:21:50 Verbose | OperatingSystem: Microsoft Windows NT 10.0.14393.0
05:21:50 Verbose | OsBitVersion: x64
05:21:50 Verbose | Is64BitProcess: True
05:21:50 Verbose | CurrentUser: NT AUTHORITY\SYSTEM
05:21:50 Verbose | MachineName: pkrvmtrqonemf4x
05:21:50 Verbose | ProcessorCount: 2
05:21:50 Verbose | CurrentDirectory: C:\Octopus\Tentacle\Work\20200820052149-748-6
05:21:50 Verbose | TempDirectory: C:\windows\TEMP
05:21:50 Verbose | HostProcess: Calamari (1908)
05:21:50 Verbose | Package Educanist version 267 hash 0534438341b17dab7107f3b7b9673c425232bd1c has not been uploaded.
05:21:50 Verbose | Finding earlier packages that have been uploaded to this Tentacle.
05:21:50 Verbose | No earlier packages for Educanist has been uploaded
05:21:50 Verbose | Found 0 earlier versions of Educanist on this Tentacle
05:21:50 Verbose | Process C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\Octopus\Tentacle\Work\20200820052149-748-6 exited with code 0
05:21:50 Verbose | Exit code: 0
05:21:50 Info | No earlier versions of Educanist were found on the target so we can’t perform a delta upload.
05:21:50 Info | Uploading package Educanist (39.304 MB)…
05:21:50 Verbose | Requesting upload…
05:21:50 Info | Beginning streaming transfer of Educanist@S267@06D81BC3813C5F44B09C7EF50570D376.nupkg
05:21:53 Info | Stream transfer complete
|
| == Failed: Step 4: Upload Files By FTP From Package ==
05:23:20 Fatal | The step failed: Activity Upload Files By FTP From Package on a Worker failed with error ‘The remote script failed with exit code 1’.
05:23:20 Verbose | Upload Files By FTP From Package completed
|
| == Failed: Worker ==
05:21:53 Verbose | Octopus Server version: 2020.3.3+Branch.tags-2020.3.3.Sha.dcb8c7449b4a13fecfcbcb9ca49d3147d434eb12
05:21:53 Verbose | Environment Information:
| IsRunningInContainer: True
| OperatingSystem: Linux 4.15.0-1089-azure #99~16.04.1-Ubuntu SMP Fri Jun 5 15:30:32 UTC 2020
| OsBitVersion: x64
| Is64BitProcess: True
| CurrentUser: root
| MachineName: octopus-i015781-897ff49fb-9qjlg
| ProcessorCount: 2
| CurrentDirectory: /Octopus
| TempDirectory: /tmp/
| HostProcessName: Octopus.Server
| PID: 1
05:21:53 Verbose | Executing Upload Files By FTP From Package (type Run a Script) on DynamicWorker 20-08-20-0434-tdjqn
05:21:53 Verbose | Using Calamari.netfx 13.0.10
05:21:53 Verbose | Using Calamari.linux-x64 13.0.10
05:21:54 Verbose | Starting C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in working directory ‘C:\Octopus\Tentacle\Work\20200820052153-748-7’ using ‘OEM United States’ encoding running as ‘NT AUTHORITY\SYSTEM’ with the same environment variables as the launching process
05:21:54 Verbose | Calamari Version: 13.0.10
05:21:54 Verbose | Environment Information:
05:21:54 Verbose | OperatingSystem: Microsoft Windows NT 10.0.14393.0
05:21:54 Verbose | OsBitVersion: x64
05:21:54 Verbose | Is64BitProcess: True
05:21:54 Verbose | CurrentUser: NT AUTHORITY\SYSTEM
05:21:54 Verbose | MachineName: pkrvmtrqonemf4x
05:21:54 Verbose | ProcessorCount: 2
05:21:54 Verbose | CurrentDirectory: C:\Octopus\Tentacle\Work\20200820052153-748-7
05:21:54 Verbose | TempDirectory: C:\windows\TEMP
05:21:54 Verbose | HostProcess: Calamari (856)
05:21:56 Verbose | Considering ‘FtpPackage’ for extraction
05:21:56 Info | Extracting package ‘C:\Octopus\Tentacle\Files\Educanist@S267@06D81BC3813C5F44B09C7EF50570D376.nupkg’ to ‘C:\Octopus\Tentacle\Work\20200820052153-748-7\FtpPackage’
05:22:15 Verbose | Performing variable substitution on ‘C:\Octopus\Tentacle\Work\20200820052153-748-7\Script.ps1’
05:22:15 Verbose | Executing ‘C:\Octopus\Tentacle\Work\20200820052153-748-7\Script.ps1’
05:22:15 Verbose | Setting Proxy Environment Variables
05:22:18 Verbose | Name Value
05:22:18 Verbose | ---- -----
05:22:18 Verbose | PSVersion 5.1.14393.3866
05:22:18 Verbose | PSEdition Desktop
05:22:18 Verbose | PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
05:22:18 Verbose | BuildVersion 10.0.14393.3866
05:22:18 Verbose | CLRVersion 4.0.30319.42000
05:22:18 Verbose | WSManStackVersion 3.0
05:22:18 Verbose | PSRemotingProtocolVersion 2.3
05:22:18 Verbose | SerializationVersion 1.1.0.1
05:22:18 Verbose | PowerShell Environment Information:
05:22:18 Verbose | OperatingSystem: Microsoft Windows NT 10.0.14393.0
05:22:18 Verbose | OsBitVersion: x64
05:22:18 Verbose | Is64BitProcess: True
05:22:18 Verbose | CurrentUser: NT AUTHORITY\SYSTEM
05:22:18 Verbose | MachineName: pkrvmtrqonemf4x
05:22:18 Verbose | ProcessorCount: 2
05:22:18 Verbose | CurrentDirectory: C:\Octopus\Tentacle\Work\20200820052153-748-7
05:22:18 Verbose | CurrentLocation: C:\Octopus\Tentacle\Work\20200820052153-748-7
05:22:18 Verbose | TempDirectory: C:\windows\TEMP
05:22:18 Verbose | HostProcess: powershell (2020)
05:22:18 Verbose | TotalPhysicalMemory: 4193844 KB
05:22:18 Verbose | AvailablePhysicalMemory: 3324368 KB
05:22:18 Info | PowerShell module WinSCP is not installed, downloading temporary copy …
05:23:15 Info | Importing WinSCP …
05:23:15 Info | Package was installed to: C:\Octopus\Tentacle\Work\20200820052153-748-7\FtpPackage
05:23:20 Error | OperationStopped: Connection failed.
05:23:20 Error | Connection failed.
05:23:20 Error | At C:\Octopus\Tentacle\Work\20200820052153-748-7\Script.ps1:323 char:5
05:23:20 Error | + throw $_.Exception.Message
05:23:20 Error | + ~~~~~~~~~~~~~~~~~~~~~~~~~~
05:23:20 Error | at , C:\Octopus\Tentacle\Work\20200820052153-748-7\Script.ps1: line 323
05:23:20 Error | at , C:\Octopus\Tentacle\Work\20200820052153-748-7\Bootstrap.Script.ps1: line 2160
05:23:20 Error | at , : line 1
05:23:20 Error | at , : line 1
05:23:20 Verbose | Adding journal entry:
05:23:20 Verbose |
05:23:20 Verbose |
05:23:20 Verbose |
05:23:20 Verbose | Process C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\Octopus\Tentacle\Work\20200820052153-748-7 exited with code 1
05:23:20 Verbose | Updating manifest with output variables
05:23:20 Verbose | Updating manifest with action evaluated variables
05:23:20 Fatal | The remote script failed with exit code 1
05:23:20 Fatal | The action Upload Files By FTP From Package on a Worker failed
|

The good news is it seems to have gotten farther, however, it still failed. I configured my local FTP server to run in Passive mode and was able to get it to work so I don’t think it’s related to that. What does your entry for Host look like? The error indicates it failed to connect to the FTP server so we may be close to getting it to work.

In your Hostname, do you have ftp:// by chance? Or is it just the hostname?

Yes Shawn the Hostname does start with ftp://. Should I change it to only the IP?

Ah!!! Yes, it only needs the host name (or IP in your case). Give that a go and let me know if it worked :slight_smile: