如何通过管道将Strapi部署到Azure

时间:2020-05-12 15:47:56

标签: azure-devops azure-pipelines web-deployment strapi

我对Strapi并不陌生,这是我第一次部署它。 我在MongoDB(Atlas)上有Strapi,可在localhost上工作。 现在,我要将MongoDb保留在Atlas上,以部署到Azure。

所以我现在的工作是

enter image description here

  1. 身份验证
  2. npm安装
  3. PowerShell->安装trapi cli并构建我的trapi项目

enter image description here

我在最后一步遇到错误。

enter image description here

我的问题是 “是否可以在Azure上使用管道来部署Strapi?” 和 “有人可以解释我该怎么做吗?”。

我将不胜感激!

1 个答案:

答案 0 :(得分:0)

以上错误是由于未将bandi安装位置添加到代理计算机的PATH环境变量中引起的。

您将必须将trapdi安装位置添加到PATH环境变量中。

在脚本任务中运行echo "##vso[task.setvariable variable=PATH]${env:PATH};installationFolder",以在托管代理计算机上设置PATH环境变量。在此处查看有关setting variables in scripts

的更多信息

在托管代理上,yarn的默认安装位置为C:\npm\prefix\bin,而不是%LOCALAPPDATA%\Yarn\bin。请参见此similar thread

因此,powershell脚本看起来像这样echo "##vso[task.setvariable variable=PATH]${env:PATH};C:\npm\prefix\bin"。请参见下面的屏幕截图。

enter image description here

注意:

在托管代理上更改PATH环境变量将仅在以下任务中生效。您需要在单独的Powershell任务中运行strapi build。见下文:

在以下powershell任务中运行Stradi build

enter image description here