[英]Deploying an Angular app with Azure Pipeline, Failed
I've built an Angular app that runs fine from localhost.我已经构建了一个 Angular 应用程序,它可以从 localhost 正常运行。 I uploaded it to a GitHub repository and I am trying to connect it to an Azure Pipeline.我将它上传到 GitHub 存储库,我正在尝试将它连接到 Azure 管道。 But it always fails on NPM Install and Build.但它在 NPM 安装和构建时总是失败。 I am new to using Azure Pipelines and think that I may be running something incorrectly.我是使用 Azure 管道的新手,我认为我可能运行不正确。 Below is the yaml that was generated for me.下面是为我生成的 yaml。
# Node.js with Angular
# Build a Node.js project that uses Angular.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install -g @angular/cli
npm install
ng build --prod
displayName: 'npm install and build'
Deploying an Angular app with Azure Pipeline, Failed使用 Azure 管道部署 Angular 应用程序,失败
Since it works fine on your local, so the error should comes from the pipeline settings.由于它在您的本地工作正常,因此错误应该来自管道设置。
Please check if the following points that may cause errors are helpful to you:请检查以下可能导致错误的几点是否对您有帮助:
First, when you create a pipeline, you need select the Github as the source location:首先,创建管道时,需要 select 和 Github 作为源位置:
Second, we need specify the working folder when we build the Angular app , the working folder should be the relative path to the .yml
.其次,我们需要在构建 Angular 应用程序时指定工作文件夹,工作文件夹应该是.yml
的相对路径。
So, I need specify the working foler when I build the Angular app by pushd /path/to/dir
:因此,当我通过pushd /path/to/dir
构建 Angular 应用程序时,我需要指定工作文件夹:
- script: |
npm install -g @angular/cli
npm install
pushd AngularDemo/AngularDemo/ClientApp
ng build --prod
popd
displayName: 'npm install and build'
As test, I could build the Angular app successfully with Azure devops pipeline.作为测试,我可以使用 Azure devops 管道成功构建 Angular 应用程序。
If above not help you, please share your build error log and file directory structure on github.如果以上对您没有帮助,请在 github 上分享您的构建错误日志和文件目录结构。
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.