Azure Static Web Apps 无法构建简单的 HTML 网页:无法从存储库中检测到语言。

huangapple go评论42阅读模式
英文:

azure static web apps fail to build simple html web page: Could not detect the language from repo

问题

我的DevOps Git项目看起来像这样:

index.html
my.js
my.css

然后管道报告以下错误:

检测平台...
未能在源目录中检测到任何平台。
错误:无法从仓库中检测语言。
---Oryx构建日志结束---
Oryx 无法确定构建步骤。继续假设此文件夹中的资源已经构建完成。如果这是意外行为,请联系支持。
发生了未知异常
有关详细信息,请访问 Azure 静态 Web 应用文档:https://docs.microsoft.com/en-us/azure/static-web-apps/
如果您认为这种行为是意外的,请在 https://github.com/azure/static-web-apps/issues/ 上提出 GitHub 问题。
退出
##[error]错误:进程'/usr/bin/bash' 以退出代码 1 失败
正在完成:AzureStaticWebApp

Azure 添加了此构建文件:

name: Azure Static Web Apps CI/CD

pr:
  branches:
    include:
      - main
trigger:
  branches:
    include:
      - main

jobs:
- job: build_and_deploy_job
  displayName: 构建和部署作业
  condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
  pool:
    vmImage: ubuntu-latest
  variables:
  - group: Azure-Static-Web-Apps-xxx-variable-group
  steps:
  - checkout: self
    submodules: true
  - task: AzureStaticWebApp@0
    inputs:
      azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_xxx)
###### 存储库/构建配置 - 可以配置这些值以匹配您的应用要求。 ######
# 有关静态 Web 应用工作流配置的更多信息,请访问:https://aka.ms/swaworkflowconfig
      app_location: "/" # 应用源代码路径
      api_location: "" # API 源代码路径 - 可选
      output_location: "/" # 构建的应用内容目录 - 可选
###### 存储库/构建配置的结束 ######

我也尝试过这行:

output_location: ""

但仍然出现相同的错误。

在 Azure 静态 Web 应用的“应用程序设置”中,我尝试了以下内容:

ENABLE_ORYX_BUILD = false

这有所改进,但仍然失败。

尝试添加一个虚拟的 package.json,以防止 Azure 尝试使用 npm。将此 package.json 放在根目录中:

{
  "name": "xxxx",
  "version": "0.0.1",
  "description": "xxxx",
  "main": "index.js",
  "repository": "git@ssh.dev.azure.com:v3/xxxx",
  "author": "x@y.com",
  "license": "MIT",
  "private": true,
  "scripts": {
    "start": "npx live-server"
  }
}

这会导致以下错误:

检测平台...
检测到以下平台:
  nodejs: 16.19.0
版本'16.19.0'的平台'nodejs'未安装。正在生成脚本以安装它...
错误:在 package.json 中找不到'build'或'build:azure'节点下的脚本。找不到使用环境变量键'RUN_BUILD_COMMAND'的自定义运行构建命令的值。找不到用于构建 monorepos 的工具,未找到'lerna.json'或'lage.config.js'文件。

希望这些信息对您有帮助。

英文:

my devops git project looks like this:

index.html
my.js
my.css

The pipeline then gives this error:

Detecting platforms...
Could not detect any platform in the source directory.
Error: Could not detect the language from repo.


---End of Oryx build logs---
Oryx was unable to determine the build steps. Continuing assuming the assets in this folder are already built. If this is an unexpected behavior please contact support.
An unknown exception has occurred

For further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/en-us/azure/static-web-apps/
If you believe this behavior is unexpected, please raise a GitHub issue at https://github.com/azure/static-web-apps/issues/
Exiting
##[error]Error: The process '/usr/bin/bash' failed with exit code 1
Finishing: AzureStaticWebApp

Azure added this build file:

name: Azure Static Web Apps CI/CD

pr:
  branches:
    include:
      - main
trigger:
  branches:
    include:
      - main

jobs:
- job: build_and_deploy_job
  displayName: Build and Deploy Job
  condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
  pool:
    vmImage: ubuntu-latest
  variables:
  - group: Azure-Static-Web-Apps-xxx-variable-group
  steps:
  - checkout: self
    submodules: true
  - task: AzureStaticWebApp@0
    inputs:
      azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_xxx)
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
      app_location: "/" # App source code path
      api_location: "" # Api source code path - optional
      output_location: "/" # Built app content directory - optional
###### End of Repository/Build Configurations ######

I also tried it with this line:

  output_location: "" 

but get same error.

In the "application settings" in azure static web app "configuration" page, I tried the following:

  ENABLE_ORYX_BUILD = false

This got a bit further, but still failed.

tried adding this:

inputs:
  skip_app_build: true

Which gives this error:

 App Directory Location: '/' was found.
 Looking for event info
 Skipping step to build /working_dir with Oryx
 An unknown exception has occurred

==== update ====
Also tried adding a dummy package.json, in case there is no way to avoid azure trying to use npm. using this package.json in the root:

{
  "name": "xxxx",
  "version": "0.0.1",
  "description": "xxxx",
  "main": "index.js",
  "repository": "git@ssh.dev.azure.com:v3/xxxx",
  "author": "x@y.com",
  "license": "MIT",
  "private": true,
  "scripts": {
    "start": "npx live-server"
  }
}

gave this error:

Detecting platforms...
Detected following platforms:
  nodejs: 16.19.0
Version '16.19.0' of platform 'nodejs' is not installed. Generating script to install it...
Error: Could not find either 'build' or 'build:azure' node under 'scripts' in package.json. Could not find value for custom run build command using the environment variable key 'RUN_BUILD_COMMAND'.Could not find tools for building monorepos, no 'lerna.json' or 'lage.config.js' files found.

答案1

得分: 0

我今天再次尝试了一下,现在正在构建。问题要么是:

  1. Azure构建系统在某些天内出现故障。
  2. 我删除了项目中的一个文件,这个文件是一个符号链接,不应该存在。
英文:

I tried it again today, and its now building. The issue was either

  1. azure build system was broken for some days
  2. I deleted one file in the project which was a symbolic link which should not have been there.

huangapple
  • 本文由 发表于 2023年4月13日 23:01:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76006974.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定