编译构建 CodeArts Build-使用Npm构建:代码化构建

时间:2025-02-12 15:15:01

代码化构建

参考以下代码示例,修改在创建代码化构建使用的YAML文件中的BUILD部分代码信息。

 1 2 3 4 5 6 7 8 91011121314151617181920
version: 2.0 # 必须是2.0steps:  BUILD:    - npm:        image: cloudbuild@nodejs8.11.2        inputs:           command: |              export PATH=$PATH:~/.npm-global/bin              npm config set registry https://repo.example.com/repository/npm/              npm config set disturl https://repo.example.com/nodejs              npm config set sass_binary_site https://repo.example.com/node-sass/              npm config set phantomjs_cdnurl https://repo.example.com/phantomjs              npm config set chromedriver_cdnurl https://repo.example.com/chromedriver              npm config set operadriver_cdnurl https://repo.example.com/operadriver              npm config set electron_mirror https://repo.example.com/electron/              npm config set python_mirror https://repo.example.com/python              npm config set prefix '~/.npm-global'              npm install --verbose              npm run build         ignore_fail: true
表2 代码示例参数说明

参数

类型

说明

image

string

填写镜像地址,有以下两种格式。

  • cloudbuild@nodejs8.11.2:以cloudbuild开始,@作为分隔符,后面是CodeArts Build提供的默认镜像版本。
  • 完整的swr镜像地址,例如:swr.example.example.com/codeci_test/demo:141d26c455abd6d7xxxxxxxxxxxxxxxxxxxx

command

string

配置Npm命令。更多命令使用方法可参考Node.js官网

ignore_fail

string

用于控制当前步骤执行失败后是否继续执行下一个步骤。
  • true:是。
  • 为空:否。
support.huaweicloud.com/usermanual-codeci/codeci_ug_0007.html