简体   繁体   English

GitLab CI/CD 构建失败

[英]GitLab CI/CD build fails

I'm trying to setup CI/CD for my ASP.NET Core/Angular project.我正在尝试为我的 ASP.NET Core/Angular 项目设置 CI/CD。 Here's what I have in my .gitlab-ci.yml :这是我的.gitlab-ci.yml中的内容:

image: mcr.microsoft.com/dotnet/core/sdk:3.0

stages:
    - build
    - test

before_script:
    - "dotnet --info"
    - "curl -sL https://deb.nodesource.com/setup_12.x | bash -"
    - "apt-get install -y nodejs"
    - "npm install -g @angular/cli"

build:
    stage: build
    script:
        - "dotnet build MySolution.sln"

test:
    stage: test
    script: 
        - "dotnet test MySolution.sln"

When I push my changes, I get the GitLab build fails with this error:当我推送我的更改时,我得到 GitLab 构建失败并出现以下错误:

EXEC: Build failed with error code: 1 [/builds/ataravati/MySolution/MySolution/MySolution.csproj] EXEC: gyp ERR: stack error: not found.执行:构建失败,错误代码:1 [/builds/ataravati/MySolution/MySolution/MySolution.csproj] 执行:gyp ERR:堆栈错误:未找到。 make [/builds/ataravati/MySolution/MySolution/MySolution:csproj] EXEC: Build failed with error code. make [/builds/ataravati/MySolution/MySolution/MySolution:csproj] EXEC:构建失败,错误代码。 1 [/builds/ataravati/MySolution/MySolution/MySolution.csproj] /builds/ataravati/MySolution/MySolution/MySolution,csproj(41:5): error MSB3073. 1 [/builds/ataravati/MySolution/MySolution/MySolution.csproj] /builds/ataravati/MySolution/MySolution/MySolution,csproj(41:5):错误 MSB3073。 The command "npm install" exited with code -1.命令“npm install”以代码 -1 退出。 0 Warning(s) 5 Error(s) 0 警告 5 错误

Time Elapsed 00:01:07.46 ERROR: Job failed: exit code 1已用时间 00:01:07.46 错误:作业失败:退出代码 1

What am I missing?我错过了什么?

UPDATE:更新:

As per tenkmilan's suggestion, I added apt-get install build-essential to the before_script section of my GitLab CI YAML file.根据 tenkmilan 的建议,我将apt-get install build-essential添加到了我的 GitLab CI YAML 文件的before_script部分。 Here's the new .gitlab-ci.yml file:这是新的.gitlab-ci.yml文件:

image: mcr.microsoft.com/dotnet/core/sdk:3.0

stages:
  - build
  - test

before_script:
  - "dotnet --info"
  - "curl -sL https://deb.nodesource.com/setup_12.x | bash -"
  - "apt-get install -y nodejs"
  - "node --version"
  - "apt-get install -y build-essential"
  - "npm install -g @angular/cli"

build:
  stage: build
  script:
    - "dotnet build MySolution.sln"

test:
  stage: test
  script:
    - "dotnet test MySolution.sln"

But, the build still fails with the following error:但是,构建仍然失败并出现以下错误:

../../nan/nan_object_wrap.h(124,26): error G90FC5925: 'class Nan::Persistent' has no member named 'IsNearDeath' [/builds/ataravati/MySolution/MySolution/MySolution.csproj] EXEC: gyp ERR: stack error : make failed with exit code: 2 [/builds/ataravati/MySolution/MySolution/MySolution.csproj] EXEC: Build failed with error code: 1 [/builds/ataravati/MySolution/MySolution/MySolution.csproj] /builds/ataravati/MySolution/MySolution/MySolution.csproj(41,5): error MSB3073: The command "npm install" exited with code -1. ../../nan/nan_object_wrap.h(124,26):错误 G90FC5925:“类 Nan::Persistent”没有名为“IsNearDeath”的成员 [/builds/ataravati/MySolution/MySolution/MySolution.csproj] 执行: gyp ERR:堆栈错误: make失败,退出代码:2 [/builds/ataravati/MySolution/MySolution/MySolution.csproj] 执行:构建失败,错误代码:1 [/builds/ataravati/MySolution/MySolution/MySolution.csproj] /builds/ataravati/MySolution/MySolution/MySolution.csproj(41,5):错误 MSB3073:命令“npm install”退出,代码为 -1。 42 Warning(s) 21 Error(s) 42 警告 21 错误

Time Elapsed 00:05:01.00 ERROR: Job failed: exit code 1已用时间 00:05:01.00 错误:作业失败:退出代码 1

I was not able to reproduce the above-written problem.我无法重现上述问题。 It seems that while your npm install is running the compiling of node-sass fails.似乎您的npm install正在运行node-sass的编译失败。

I created an example repo with a simple CI:我用一个简单的 CI 创建了一个示例 repo:

https://gitlab.com/tenkmilan/angular-dotnet-core-example https://gitlab.com/tenkmilan/angular-dotnet-core-example

The CI configuration is following: CI配置如下:

image: mcr.microsoft.com/dotnet/core/sdk:3.0

stages:
  - build

before_script:
  - "dotnet --info"
  - "curl -sL https://deb.nodesource.com/setup_12.x | bash -"
  - "apt-get install -y nodejs"
  - "node --version"

build:
  stage: build
  script:
    - "dotnet build my-new-app.csproj"

In my example, in the build step I use the .csproj file instead of .sln .在我的示例中,在构建步骤中,我使用.csproj文件而不是.sln This can be a good starting point for further investigation.这可能是进一步调查的良好起点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM