如何在VSTS上配置构建以通过FTP部署 [英] How do I configure a build on VSTS to FTP deploy

查看:92
本文介绍了如何在VSTS上配置构建以通过FTP部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新项目的master分支时,我想使用VSTS来构建和部署我的应用程序(到FTP).我有下面的脚本.它的工作原理是触发并生成,但随后部署失败,因为它找不到文件,而且我也不知道要输入什么值.我收到以下错误.

I want to use VSTS to build and deploy my app (to FTP) when Update the master branch of my project. I have the script below. It works in that it triggers and builds but then fails to deploy because it can't find the files and I don't know what values to enter. I get the error below.

VSTS生成时,将生成文件放在哪里?

When VSTS builds, where does it put the build files?

我看过youtube,但是所有示例都过时了,目前尚无法反映VSTS的工作原理,因此我完全陷入了困境.这里没有文章可以反映VSTS目前的工作方式,Microsoft页面也无济于事.

I've watched youtube but all the examples are old and don't reflect how VSTS works right now so I'm totally stuck. There are no articles here that reflect how VSTS works right now and the Microsoft pages are no help either.

我的文章要用完了,现在已经不多了,我很猜测,因此,我们将不胜感激.

I'm running out of articles to review and am now pretty much guessing, so any help would be very much appreciated.

# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  buildConfiguration: 'Release'

steps:
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'

- task: FtpUpload@2
  inputs:
    credentialsOption: 'inputs'
    serverUrl: 'ftp://xxxxxxx.xxxxxxxx.xxxxx/'
    username: 'xxxxxxxxx'
    password: 'xxxxxxxxxx'
    rootDirectory: '/'
    filePatterns: '**'
    remoteDirectory: '/'
    clean: false
    cleanContents: true
    preservePaths: false
    trustSSL: false

我改成了这个

rootDirectory: $(Agent.BuildDirectory)

并尝试了

rootDirectory: $(Build.StagingDirectory)

现在构建成功,但是现在我收到此错误/警告.什么都没有部署.

And now the build succeeds but now I get this error/warning. Nothing is deployed.

推荐答案

设置system.debug=true后,打开日志进行详细的编译过程,您会看到:

When you set system.debug=true, then open the log for detailed compile process, you could see:

它正在寻找您在任务中指定的目录'/'.但是,不幸的是,使用/获得的内容不是您的存储库的任何部分.然后服务器告诉您抱歉,在您的存储库中找不到此类文件或目录.

It is looking for directory '/' which you specified in the task. But, unfortunately, the content obtained with / is not any part of your repos. Then the server tell you sorry, can not find such file or directory in your repos.

此参数是从VSTS仓库中获取文件或文件夹,因此在这里您需要使用一些单词来使服务器知道您想要从仓库中获取什么.

This parameter is getting files or folders from your VSTS repos, so here you need use some words to let server know what you want to take from Repos.

(1)由于此任务在构建管道中,因此您可以使用

(1) Since this task is in your build pipeline, you could use $(Build.SourcesDirectory) to represent for your whole repos.

(2)另外,如果您只想复制仓库的一部分,例如文件夹或文件,只需输入相对路径即可.例如:

(2) Also, if you just want to copy part of repos, such as folder or file, just input them with relative path. For example:

  • 上传文件upload.json,该文件位于文件夹jobs下, 输入rootDirectory: jobs/upload.json.
  • 上传一个文件夹或文件,该文件夹或文件位于Repos的根路径中,只需输入 rootDirectory: {folder name}rootDirectory: {folder name}.像:rootDirectory: jobsrootDirectory: web.config
  • Upload the file upload.json which under the folder jobs, just input rootDirectory: jobs/upload.json.
  • Upload one folder or file which in the root path of Repos, just input rootDirectory: {folder name}, or rootDirectory: {folder name}. Like: rootDirectory: jobs, or rootDirectory: web.config

这篇关于如何在VSTS上配置构建以通过FTP部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆