我的 MS Teams 应用程序(聊天机器人)在本地、测试工具和 Azure 中配置、部署和运行良好。
因此,我决定最终更进一步,设置 CI/CD,因为我已经为所有其他项目设置了它。然而,这是我第一次为 Node.js 项目设置 CI/CD。
我正在按照有关如何使用 Azure DevOps 设置管道的说明进行操作,但是使用以下命令执行 npx teamsapp deploy
命令时部署步骤失败:
Starting: Deploy to Azure
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.237.1
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/45easss6-ddd-4c39-9b3c-xxx.sh
(✖) Error: coordinator.InvalidProjectError: This command only works for project created by Teams Toolkit.
##[error]Bash exited with code '1'.
Finishing: Deploy to Azure
我的 teamsapp.yml 对于 Teams Toolkit 应用程序来说非常标准,所以我不确定为什么部署脚本会认为该项目不是由 Teams Toolkit 创建的?
使用的 YAML 管道代码:
trigger:
- dev
pool:
vmImage: ubuntu-latest
variables:
TEAMSAPP_CLI_VERSION: 3.0.0
steps:
- task: NodeTool@0
inputs:
versionSpec: "20"
checkLatest: true
- script: |
npm install @microsoft/teamsapp-cli@$(TEAMSAPP_CLI_VERSION)
displayName: "Install CLI"
- script: |
npx teamsapp auth login azure --username $(AZURE_SERVICE_PRINCIPAL_CLIENT_ID) \
--service-principal true \
--tenant $(AZURE_TENANT_ID) \
--password $(AZURE_SERVICE_PRINCIPAL_CLIENT_SECRET) \
--interactive false
displayName: "Login to Azure by service principal"
- script: |
npx teamsapp deploy \
--ignore-env-file true \
--interactive false
displayName: "Deploy to Azure"
workingDirectory: $(System.DefaultWorkingDirectory)
- script: |
npx teamsapp package
displayName: "Package app"
workingDirectory: $(System.DefaultWorkingDirectory)
- publish: $(System.DefaultWorkingDirectory)/appPackage/build/appPackage.zip
artifact: artifact
我的团队app.yml:
# Triggered when 'teamsfx deploy' is executed
deploy:
# Run npm command
- uses: cli/runNpmCommand
name: install dependencies
with:
args: install
- uses: cli/runNpmCommand
name: build app
with:
args: run build --if-present
# Deploy your application to Azure App Service using the zip deploy feature.
# For additional details, refer to https://aka.ms/zip-deploy-to-app-services.
- uses: azureAppService/zipDeploy
with:
# Deploy base folder
artifactFolder: .
# Ignore file location, leave blank will ignore nothing
ignoreFile: .webappignore
# The resource id of the cloud resource to be deployed to.
# This key will be generated by arm/deploy action automatically.
# You can replace it with your existing Azure Resource id
# or add it to your environment variable file.
resourceId: ${{BOT_AZURE_APP_SERVICE_RESOURCE_ID}}
./teamsapp.yml
路径相对于npx命令执行目录是可访问的?