【发布时间】:2020-09-16 01:16:25
【问题描述】:
我无法理解和获取将 NestJS 应用程序部署到 Azure DevOps (ADO) 的构建/发布管道设置。
我正在部署到托管在 Azure 中的 Linux Web 应用程序。
据我了解,如果我使用 npm run start 之类的东西在本地运行应用程序,它会在我的项目根目录下创建一个 dist 文件夹。
因此,在为构建和部署编写 YAML 时。我的思考过程是:
- 运行 NPM 更新。
- 运行
npm run build以构建应用程序并生成dist文件夹。 - 将应用程序的内容(或只是 dist 文件夹?)复制到目标文件夹 (
/home/site/wwwroot) - 运行
npm run start:prod启动服务器。
到目前为止,这是我的 YAML:
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseNode@1
inputs:
version: '14.x'
checkLatest: true
- task: Npm@0
displayName: Run NPM Update for NestJS
inputs:
cwd: '$(Build.SourcesDirectory)/ProjectName'
command: update
- task: Npm@0
displayName: Build NestJS
inputs:
cwd: '$(Build.SourcesDirectory)/ProjectName'
command: run
arguments: "build"
- task: CopyFiles@2
inputs:
Contents: 'dist/**'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
问题是在构建过程完成后,我在/home/site/wwwroot/ProjectName 中看不到dist 文件夹。有人可以帮我解决我所缺少的吗?
另外,关于 Azure DevOps 的一个小白问题,$(Build.SourcesDirectory) 和 $(Build.ArtifactStagingDirectory) 指的是什么以及这些环境变量是如何以及在哪里设置的?
【问题讨论】:
标签: node.js azure-devops azure-pipelines nestjs azure-pipelines-release-pipeline