'How to upload zip file on remote server using Azure DevOps
I am using Azure Deveops
for build
and release
my MVC website to the different client machines. I was successfully able to build and release .Net Core
application to the remote server but with that I also want to upload some initial file which contains .json files that I want to upload on remote server (client's machine).
What I have tried
I have tried to used Windows Machine File Copy task and Copy Files task , but this didn't work for me.
Please provide me suggestions or solution to upload files on remote server using Azure devops.
Solution 1:[1]
Create a Deployment Group and install an agent to the target machine. When running a release, it fetches the build artifacts to the target server and you'll be able to use, for example, a normal copy task to copy the zip.
Alternative, if you just need to run the release on agent located somewhere else (hosted agent, agent running on build server, etc), you could use WinRM copy -extension to copy the files. You'd, of course, need to enable WinRM calls between the machines.
Solution 2:[2]
I have used several of these types of tasks:
Copy File Task (https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/copy-files?view=azure-devops&tabs=yaml)
Copy Files of SSH (https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/copy-files-over-ssh?view=azure-devops)
Curl Upload Files (https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/curl-upload-files?view=azure-devops)
FTP (https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/ftp-upload?view=azure-devops)
(Windows only) Windows Machine File Copy (https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/windows-machine-file-copy?view=azure-devops)
Alternatively, use a script task and write the command you want to use. I had a scenario where my agent was on Linux and I needed to push files to a Windows Server. I ended up using a Bash Smbclient like this:
- task: Bash@3
displayName: "Copy/Upload file to remote server"
inputs:
targetType: 'inline'
script: |
apt-get update && apt-get install -y smbclient
smbclient -U "$([email protected])%$(password)" //my.network.server/share --directory '/path/to/location/' -c 'put myfile.zip'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | JukkaK |
Solution 2 | duyn9uyen |