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:
- From your Jenkins job's configuration screen, add a Build step of "Execute Shell"
- Add the following command into it:
eslint -c config.eslintrc -f checkstyle apps/**/* > eslint.xml
(replace apps/**/*
to the path of your app files)
- 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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…