GitLab CI / CD构建失败

时间:2019-11-22 01:47:20

标签: angular asp.net-core gitlab-ci

我正在尝试为我的ASP.NET Core / Angular项目设置CI / CD。这是我的.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"

当我推送更改时,我得到的GitLab构建失败,并显示以下错误:

  

EXEC:构建失败,错误代码:1   [/builds/ataravati/MySolution/MySolution/MySolution.csproj] EXEC:gyp   呃!堆栈错误:未找到:make   [/builds/ataravati/MySolution/MySolution/MySolution.csproj] EXEC:   生成失败,错误代码:1   [/builds/ataravati/MySolution/MySolution/MySolution.csproj]   /builds/ataravati/MySolution/MySolution/MySolution.csproj(41,5):错误   MSB3073:命令“ npm install”以代码-1退出。 0警告5   错误

     

经过时间00:01:07.46错误:作业失败:退出代码1

我想念什么?

更新:

根据tenkmilan的建议,我在GitLab CI YAML文件的apt-get install build-essential部分中添加了before_script。这是新的.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"

但是,构建仍然失败,并出现以下错误:

  

../../ nan / nan_object_wrap.h(124,26):错误G90FC5925:“类   Nan :: Persistent'没有名为'IsNearDeath'的成员   [/builds/ataravati/MySolution/MySolution/MySolution.csproj] EXEC:   糟糕!堆栈错误:make失败,退出代码:2   [/builds/ataravati/MySolution/MySolution/MySolution.csproj] EXEC:   生成失败,错误代码:1   [/builds/ataravati/MySolution/MySolution/MySolution.csproj]   /builds/ataravati/MySolution/MySolution/MySolution.csproj(41,5):   错误MSB3073:命令“ npm install”退出,代码为-1。       42警告       21个错误

     

经过时间00:05:01.00错误:作业失败:退出代码1

1 个答案:

答案 0 :(得分:0)

我无法重现上述问题。看来npm install运行时node-sass的编译失败。

我用一个简单的CI创建了一个示例仓库:

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

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"

在我的示例中,在构建步骤中,我使用.csproj文件而不是.sln文件。这可能是进一步研究的良好起点。