我应该为静态网站的 Azure Pipeline 的 rootDirectory 指定什么?

What's should I specify for the rootDirectory of an Azure Pipeline for a static website?

我管理一个静态网站。没有数据库,没有像 ASP.NET (IIS)、PHP 等服务器端处理。这个网站仅由 HTML、CSS、一些 JavaScript 组成和一些图形文件。我正尝试为此使用 Azure Pipelines。这是我第一次使用 Azure Pipelines。我选择了一个 HTML 模板来启动 YAML 管道。

我正在使用 FTP Upload 任务。源代码位于 Azure DevOps Repos 中。我通过尝试将文件 FTP 到托管服务器(不是 Azure 的一部分)上的测试文件夹来测试管道。在测试管道时,出现此错误:

##[error]Error: Failed find: ENOENT: no such file or directory, stat '/bin/pyvenv'

我不知道应该把什么作为根目录。我认为放置“/”是合适的。这是 YAML:

# HTML
# Archive your static HTML project and save it with the build record.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- none

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(build.sourcesDirectory)'
    includeRootFolder: false

- task: FtpUpload@2
  inputs:
    credentialsOption: 'inputs'
    serverUrl: 'ftp://ftp.destination.com'
    username: '$(TheUsername)'
    password: '$(ThePassword)'
    rootDirectory: '/'
    filePatterns: '**'
    remoteDirectory: '/test'
    clean: false
    cleanContents: false
    preservePaths: false
    trustSSL: false

我应该为 rootDirectory 添加什么?

你试过了吗 rootDirectory: '.' 要么 rootDirectory: '$(Pipeline.Workspace)' ?

任务ArchiveFiles字段archiveFile默认值为$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip

根据您的 YAML 构建定义,您已将文件夹 $(build.sourcesDirectory) 存档到路径 $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip,下一个任务是 FtpUpload,那么字段 roo​​tDirectory 应该是 $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip 并且它将将 zip 文件上传到远程计算机。

如果要上传静态网站,也可以设置字段rootDirectory为$(Build.SourcesDirectory)。查看文档 build variables 了解更多详情。

根目录是编译代码所在的源代码目录,在您的情况下应该是结帐路径。

我认为你应该使用 should use $(System.DefaultWorkingDirectory)/rootFolderName.

这里的根文件夹应该是你的仓库名称。您尝试打印 $(System.DefaultWorkingDirectory) 的内容以检查您是否需要仅使用 $(System.DefaultWorkingDirectory) 或其中的任何嵌套文件夹。