【问题标题】:How do I create a build pipeline using TFS/GIT that will deploy to non Azure ftp?如何使用将部署到非 Azure ftp 的 TFS/GIT 创建构建管道?
【发布时间】:2021-02-20 22:49:28
【问题描述】:

我想创建一个构建管道,以便在我签入 tfs-git 时,构建的应用程序将通过 ftp 进行部署。

ftp 站点不在 Azure 上,我有自己的外部主机。

我的管道成功构建了应用程序,但现在我需要将其部署到外部 FTP 站点。

我已经尝试了一段时间,但找不到任何说明或详细信息,有人可以帮忙吗?

谁能指点我一些对我有帮助的文章?

我想要

  1. 推送到 Git (完成)
  2. 触发构建 (完成)
  3. 创建发布文件 (不知道)
  4. 将发布文件复制到我的 FTP(非 Azure) (Ftp 可以,但是看不到如何选择发布目录)

【问题讨论】:

    标签: git visual-studio tfs ftp


    【解决方案1】:

    有一个FTP Upload task,您可以使用此任务通过文件传输协议 (FTP) 或使用 FTPS 安全地将文件上传到远程计算机。

    您可以选择将构建生成的工件发布到 Azure DevOps Server 端放置文件夹,然后使用发布管道将它们上传到远程 ftp 服务器。

    建议你看看这个分步教程:Use FTPS to deploy your WebApp using Azure DevOps

    你也可以看看下面类似的问题:

    为确保您的远程 FTP 服务器与 Azure DevOps 构建/发布代理之间的连接,请注意以下部分:

    Microsoft 托管 IP 地址是动态的。你需要下载 每周 JSON 文件并将 IP 范围添加到您的服务器。

    更多信息请参考:To identify the possible IP ranges for Microsoft-hosted agents

    对于你的场景,我建议你可以设置一个self-hosted/private agent,然后在这个代理上构建/发布。通过这种方式,您只需将该代理机器的 IP 添加到您的服务器即可。

    【讨论】:

    • 好吧,我还在挖,就像在糖浆中涉水一样。我已经让 ftp 任务工作了,我现在的问题是让管道构建和发布,然后让 ftp 任务使用发布目录的内容。
    • FTP 文章假设我正在发布到 Azure 存储,但我不是)
    【解决方案2】:

    我终于解决了 publish 参数需要在参数前有 '--' 如果您复制和粘贴命令,还要注意“和”单引号

    # 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: 'windows-2019'
    
    variables:
      buildConfiguration: 'Release'
    
    steps:
    - script: dotnet build --configuration $(buildConfiguration)
      displayName: 'dotnet build $(buildConfiguration)'
    
    - task: DotNetCoreCLI@2
      displayName: Publish
      inputs:
        command: publish
        publishWebProjects: True
        arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
        zipAfterPublish: True
    
    - task: FtpUpload@2
      displayName: 'FTP Upload'
      inputs:
          credentialsOption: inputs
          serverUrl: 'xxxxxxxx'
          username: 'xxxxxx'
          password: 'xxxxxxxx'
          remoteDirectory: '/'
          trustSSL: true
          cleanContents: true
          rootDirectory: $(Build.artifactstagingdirectory)
    

    【讨论】:

      猜你喜欢
      • 2013-11-23
      • 2021-07-15
      • 1970-01-01
      • 2020-06-08
      • 1970-01-01
      • 2017-12-18
      • 2014-06-17
      • 1970-01-01
      • 2023-03-14
      相关资源
      最近更新 更多