angular - Is there a way to provide environment.prod.ts file in a Azure CI build pipeline while building an Angular App?
问题描述
I am looking for possible ways for providing the environment.prod.ts file into the Azure CI build pipeline, as we don't check-in those environment-specific (environment.prod.ts or environment.dev.ts) files into the repo.
Is there a specific YAML task for it? How to ensure that the Azure CI pipeline can get this file in order to build the Angular application.
Thanks in Advance!
解决方案
You can use regular linux commands like echo to create a file dynamically.In this case, make sure your environments folder (src/environments) is not empty (even an empty readme.md file would work).
If it is empty then Azure CI might not create this directory while taking clone of repo.
After that, you can use echo command in your azure-pipelines script and it will look like below:-
# 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:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '14.x'
displayName: 'Install Node.js'
- script: |
echo $DEV_ENVIRONMENT>src/environments/environment.ts
echo $PROD_ENVIRONMENT>src/environments/environment.prod.ts
npm install -g @angular/cli
npm install
ng build --prod
displayName: 'npm install and build'
Check echo command under scripts.
I've stored contents of environment.ts and environment.prod.ts in DEV_ENVIRONMENT and PROD_ENVIRONMENT so that developer doesn't know what's inside the file.
推荐阅读
- c# - PDF 到文本转换 - 下一页中的多行
- laravel - 作曲家更新后Laravel Passport未经身份验证
- html - 相对于侧面缩放块
- apple-push-notifications - registerForRemoteNotifications 在大苏尔根本不起作用?
- javascript - 在 Vuetify 组合框中更新模型的问题
- python - 获得非常高的平方误差值和奇怪的斜率
- javascript - 如何读取多个复选框(以及与之关联的数据)?
- javascript - 解析事件对象数组并匹配具有正确开始停止日期的状态集
- javascript - 当用户点击地址栏输入使用 JQuery 或 JS 时,如何防止网页重新加载
- postgresql - 在 python 和 postgresql 中导致零插入/更新问题