Jenkins Plugin Tips and Tricks - Part 1


In this section I will talk about Tips, Tricks, Troubleshooting of jenkins plugins.


Role strategy Plugin

This plugin adds a new role-based strategy to ease and fasten users management. You can even define pattern for the job and assign access for those jobs to users.

Tip - > While specifying the pattern add the "." before "*", Otherwise pattern will not work. Ex-

              test* will not match the job name which starts with test, You will need to add "." like test.* to match the job name starts with test.





Configuration Slicing Plugin

If you want to change configuration of multiple jobs (may be 100s), Its not easy to change each jobs one by one. This plugin allows you to change the configuration of jobs in bunch.
But you can see following error some time when you  change the configuration.


 Oops!



A problem occurred while processing the request. Please check our bug tracker to see if a similar problem has already been reported. If it is already reported, please vote and put a comment on it to let us gauge the impact of the problem. If you think this is a new issue, please file a new issue. When you file an issue, make sure to add the entire stack trace, along with the version of Jenkins and relevant plugins. The users list might be also useful in understanding what has happened.

Stack trace

javax.servlet.ServletException: java.lang.IllegalStateException: Form too large 569117>200000
 at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:783)
 at org.kohsuke.stapler.Stapler.invoke(Stapler.java:863)
 at org.kohsuke.stapler.MetaClass$12.dispatch(MetaClass.java:390)
 at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:733)
 at org.kohsuke.stapler.Stapler.invoke(Stapler.java:863)
 at org.kohsuke.stapler.MetaClass$12.dispatch(MetaClass.java:390)
 at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:733)
 at org.kohsuke.stapler.Stapler.invoke(Stapler.java:863)
 at org.kohsuke.stapler.Stapler.invoke(Stapler.java:636)
 at org.kohsuke.stapler.Stapler.service(Stapler.java:225)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1494)
 at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:96)
 at hudson.plugins.scm_sync_configuration.extensions.ScmSyncConfigurationFilter$1.call(ScmSyncConfigurationFilter.java:46)
Reason -> Because there are too many values to be changed. You can see it says "Form too large 569117>200000" Your value has to be less then 200000.
Solution -> Try to change configuration for lessen number of jobs at a time.

Unit Test Results (Junit and Testng) Publish


Unit test in java code can be written with Junit or testng for projects. Now, problem starts here to support multiple types of unit test types in your build or CI system (Jenkins).

Use Junit test Report generator, because it support parsing of test result xml files of both Junit and testng. (Testng plugin does not support Junit style xml file parsing).

You can define patter like this



Few examples -> 
**/target/surefire-reports/testng-results.xml, **/build/test-reports/*.xml, **/target/surefire-reports/*.xml, **/test-output/**/TEST-*.xml

Above pattern can search any xml file which has test results (Junit and testng both) and provide you integrated result in a graph.
This way you don't need to worry about the what unit test are there in project, Your plugin and pattern will get the report and publish it.




JDK Parameter Plugin

This plugin adds a build parameter which can be used to set the JDK to be used with a job on a per-build basis. The JDKs that can be chosen from can be specified on the configuration page of any job that has the JDK parameter enabled But there is small glitch on this.

You have to make JDK as parameter as per plugin document which will get the JDK version and pass it to the actual JDK  option.



Many times it happens that JDK parameter will not pass the selected version of JDK for the build.

Make sure you do set this JDK as default and do not set this to any specific version.
If you set this JDK to specific version, the JDK parameter plugin will not be able to pass the selected version.

Comments

Post a Comment

Popular posts from this blog

Colour formatting - Jenkins Console

Manage Docker images on local disk

How to migrate Parent pom from maven to gradle