【发布时间】:2019-08-07 05:34:42
【问题描述】:
我正在使用 Azure Pipelines GitHub 插件来确保拉取请求通过我的 linting。但是,我刚刚提出了一个测试拉取请求,但我的 linting 失败了,但 Azure 管道成功了。
这是我的azure-pipelines.yml
# Node.js with React
# Build a Node.js project that uses React.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- master
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '8.x'
displayName: 'Install Node.js'
- script: |
npm install
npm run lint # Mapped to `eslint src` in package.json
npm run slint # `stylelint src` in package.json
npm run build
displayName: 'npm install and build'
这是我知道在npm run lint 上失败的分支上的(部分)输出
> geograph-me@0.1.0 lint /home/vsts/work/1/s
> eslint src
/home/vsts/work/1/s/src/js/components/CountryInput.js
26:45 error 'onSubmit' is missing in props validation react/prop-types
27:71 error 'onSubmit' is missing in props validation react/prop-types
✖ 2 problems (2 errors, 0 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! geograph-me@0.1.0 lint: `eslint src`
npm ERR! Exit status 1 # Exit status 1, yet the build succeeds?
npm ERR!
npm ERR! Failed at the geograph-me@0.1.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vsts/.npm/_logs/2019-03-16T05_30_52_226Z-debug.log
> geograph-me@0.1.0 slint /home/vsts/work/1/s
> stylelint src
> geograph-me@0.1.0 build /home/vsts/work/1/s
> react-scripts build
Creating an optimized production build...
Compiled successfully.
# Truncated...
如您所见,linter 运行良好并捕获了我的故意错误(我删除了一个 prop 类型验证),并以代码 1 退出。
然而构建只是继续其愉快的方式。
我需要怎么做才能使这样的 linting 错误停止我的构建并且不返回成功?
提前谢谢你。
【问题讨论】:
-
您是否想出一种方法来在管道的摘要选项卡中报告这些 lint 错误/警告?
标签: azure azure-devops pipeline devops azure-pipelines