如何将Eslint与jenkins集成? [英] How to integrate Eslint with jenkins?

查看:795
本文介绍了如何将Eslint与jenkins集成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Eslint与jenkins集成在一起,但是我没有在Google中找到任何链接,请您为此提供帮助。



等待您的光临



谢谢,
Siva ramanjaneyulu vegi

解决方案

您需要将







更新:



使用最新版本ESLint,您可以使用以下命令行参数将输出导出到所需的任何文件中:



-o your_file.file_format



请参考其文档



注意:



如果对eslint的调用有错误,该命令将返回 1 的值,并且该构建将标记为 failed ,这不一定是必需的。为避免这种情况,请附加以下内容: ||真的


I am trying to integrate Eslint with jenkins, but i didn't found any links in google, could you please help me for this.

Awaiting for your favorable response.

Thanks, Siva ramanjaneyulu vegi

解决方案

You need to export your ESLint report into an xml file and use any of the violation/lint reporter plugins that jenkins has available like Checkstyle, Warnings or Violations plugins.

For ESLint I personally prefer using the Checkstyle plugin in Jenkins.

So the way you could export your eslint reports into Jenkins is by doing the following:

  1. From your Jenkins job's configuration screen, add a Build step of "Execute Shell"
  2. Add the following command into it: eslint -c config.eslintrc -f checkstyle apps/**/* > eslint.xml (replace apps/**/* to the path of your app files)
  3. Add a Post Build Action of "Publish Checkstyle analysis results" and input the path where your "eslint.xml" file got exported. (This is assuming you have installed the Checkstyle plugin in Jenkins)

Then, when you execute the job you will be able to see the ESLint report against the files it got executed.


Understanding what I have done with:

eslint -c config.eslintrc -f checkstyle apps/**/* > eslint.xml

  • -c config.eslintrc this point into the .eslintrc configuration file and uses whatever we specify there to use. (Please see above ESLint link I've provided)
  • -f checkstyle this will specify eslint what format it should use on the report, please see the available formats in this link
  • apps/**/* this is the path of the files you would like for eslint to check (**/* is the pattern for any files and folder)
  • > filename this is the export cli arg where the results are going to be stored each time the build is run

UPDATE:

With the latest version of ESLint you can export the output into whatever file you'd like with the following command line argument:

-o your_file.file_format

Please refer to their documentation

NOTE:

In the case that the invocation to eslint has errors, the command will return a value of 1, and the build will be marked as failed, which is not necessarily wanted. To avoid this, append the following: || true

这篇关于如何将Eslint与jenkins集成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆