Child pages
  • Collapsing Console Sections Plugin
Skip to end of metadata
Go to start of metadata

This plugin allows the creation of sections in build consoles.These sections can be individually collapsed to hide unimportant details. A floating outline widget is available to navigate through all the sections of a build.

Plugin Information

View Collapsing Console Sections on the plugin site for more information.

This plugin is up for adoption. Want to help improve this plugin? Click here to learn more!

Basic Usage

Once this plugin is installed, you can define console sections from Manage Jenkins. Each console section is defined by a display name, a Java regular expression pattern that identifies the start of the section in log files, and a second regex that identifies the end of the section.

Starting with version 1.2 of this plugin, captured groups from the start-of-section regular expression can be referenced from the section display name. Simply use {1}, {2}, and so forth in the place where you want to insert the value of the corresponding capture group of the regular expression.

After console sections have been defined, any section definition that matches contents of a visited build console URL will cause the that section to be annotated in the browser window. Visibility of the section contents can be toggled with the "Hide/Show" link.

A floating navigation widget is also inserted into the left-side navigation to aid movement between console sections.

Programmatic Usage

If you want to provide a pre-canned set of sections for your organization's Jenkins installation, you can create a plugin that depends on this plugin, and programmatically create section definitions. Create instances of SectionDefinition to define sections, and then create a ConsoleAnnotatorFactory subclass that returns an instance of CollapsingSectionAnnotator. Here is a simple example that creates a section around Subversion checkouts.

import hudson.Extension;
import hudson.console.ConsoleAnnotator;
import hudson.console.ConsoleAnnotatorFactory;
import hudson.model.Run;
import org.jvnet.hudson.plugins.collapsingconsolesections.CollapsingSectionAnnotator;
import org.jvnet.hudson.plugins.collapsingconsolesections.SectionDefinition;


@Extension
public class SubversionAnnotatorFactory extends ConsoleAnnotatorFactory<Class<Run>> {
    @Override
    public ConsoleAnnotator newInstance(Class<Run> context) {
        SectionDefinition svnSection = new SectionDefinition( "Subversion Checkout",
                "((Checking out)|(Updating) (http|https|svn\\+ssh).+",
                "At revision \\d+.+" );
        return new CollapsingSectionAnnotator( svnSection );
}

The signature for CollapsingSectionAnnotator's constructor is

public CollapsingSectionAnnotator( SectionDefinition... definitions );

so you can use a single annotator that defines multiple console sections.

Change Log

Version 1.7.0 (Jan 23, 2018)

Version 1.6.0 (June 11, 2017)

  • (plus) JENKINS-26630 - Add option for collapsing sections by default
  • (error) JENKINS-25201 - Make console sections non-floating if the content exceed the window height
  • (info) JENKINS-23121 - Add regular expression field validation to the configuration page
  • (info) Update Jenkins core requirement to 1.609.3

Version 1.5.0 (June 13, 2016)

  • (info) The new baseline is 1.532.x
  • (error) JENKINS-30690 - Lack of section definitions causes NPE and an empty console
  • (error) PR #5 - Fix cursor type in section headers from hand to pointer
  • (info) Migration to the new Jenkins plugin parent POM

Version 1.4.1 (November 04, 2013)

Version 1.4 (October 26, 2013)

  • Indenting of sections on navigation pane
  • Automatic numbering of sections
  • Recursive termination of sections by a single log line can be disabled
  • Fixed a bug with sections appearance in Internet Explorer (JENKINS-15568)

Version 1.3 (November 11, 2010)

  • [JENKINS-8078] Work around problem that causes SCM polling logs to not be displayed.

Version 1.2 (November 4, 2010)

  • Allow content of captured groups of the starting regular expression to be used in the section header.
  • Escape section header on output to prevent XSS exploits.

Version 1.1 (November 3, 2010)

  • Fixed bug where navigation widget overlaps into console area when floating.

Version 1.0 (November 2, 2010)

  • Initial version

6 Comments

  1. Could you add a way of easily defining the end of a section based on the a match in the next (rather than current) line of code please?

    This would help with console output like:

    Section 1:
    	line #1
    	line #2
    	line #3
    Section 2:
    	line #1
    	line #2		etc...
    

    Currently there is no easy way of saying "Section 1" is everything up to "Section 2".

    Otherwise, nice plugin!

  2. I want suggest you two different ideas:

    1) I think may be interesting to use in parts of the regular expression in name of the section.

    With an output like:

    Section 1
    text
    end ok
    
    Section 2
    text
    end fail
    

    The following configuration produce two sections, named "Section 1 - ok" and "Section 2 - fail"

    Section name: Section {s1} - {e1}
    Section starts with: Section (.*)
    Section ends with: end (.*)

    where:
    {s1} means first matching group of "Section starts with" regular expression
    {e1} means first matching group of "Section ends with" regular expression

    2) A simple way to alter left side menu. In the previous example I want see only "failed section"

    1. I second that, because without such a feature I would need to create MANY sections instead of on "rule"...

  3. i dont see this plugin in the "Available" list on my Jenkins server.

    what am i missing 

  4. What are the scalability concerns regarding the use of this plugin? How about processing a 20MB console log that contains ~1000 ansible tasks, can we collapse each of this tasks or it would take Jenkins down?

    There are two concerns: server load due to processing and annotated console log size increase, which are not to be ignored as we observed that quite often the annotated log file is 5-15x the size of the plaintext one.... and jenkins is converting it to HTML on every request! No caching involved....

     

    Also second question would be about lack of (or undocumented) support for pipelines. How to enable it on pipelines?

Write a comment…