Configuring yslow on Jenkins

2019-03-22 07:48发布

问题:

Could I get some help on configuring Jenkins to use yslow?

I saw on the lightning speach for yslow that it can be implemented with CI, but it didn't give very much information on how one would go about doing this. I've done quite a bit of searching on google for yslow and CI or jenkins, and have been unable to find anything.

Could anyone point me in the right direction?

回答1:

Sorry, seem like someone destroyed YSlow for PahntomJS wiki page but it's back again, check it out at: https://github.com/marcelduran/yslow/wiki/PhantomJS

There was Jenkins screenshot but no step-by-step integration, I just updated the wiki with the following:


Once you have Jenkins, PhantomJS and YSlow for PhantomJS installed and working properly, just add the following shell command into your building process:

phantomjs /tmp/yslow.js -i grade -threshold "B" -f junit http://built-page-here > yslow.xml

In line above:

  • YSlow for PhantomJS script is located at /tmp/yslow.js
  • -i grade specifies that all rules will be tested
  • -threshold "B" specifies the lowest acceptable score for all rules as well as overall score
  • -f junit specifies the output format for Jenkins
  • http://built-url-here is the reachable built page url of your project
  • yslow.xml is the output results in junit format

If you have TAP plugin installed (via Jenkins plugin manager), you can replace the line above or add another test as follows:

phantomjs /tmp/yslow.js -i grade -threshold "B" -f tap http://built-page-here > yslow.tap In line above:

  • YSlow for PhantomJS script is located at /tmp/yslow.js
  • -i grade specifies that all rules will be tested
  • -threshold "B" specifies the lowest acceptable score for all rules as well as overall score
  • -f tap specifies the output format for TAP Jenkins plugin
  • http://built-url-here is the reachable built page url of your project
  • yslow.tap is the output results in TAP format

Make sure you publish JUnit and/or TAP results report in the post-build actions pointing to the output test results file(s), e.g: yslow.xml, yslow.tap, etc.