2

I have installed once jenkins last month, and I remember the shell script in the field "Build" -> "execute shell" has syntax highlighing support.

But Now I have reinstalled jenkins today, there is no more syntax highlighting. Is there anybody can help me here?

I'm using jenkins ubuntu version 1.566

1 Answers1

2

I achieved this by involving the ace editor.

Assume you have the jQuery plugin and the simple theme plugin installed then you could add this script:

Q(function() {
    // Append the ace editor script. Change it to your script location
    Q('body').append('<script src="/userContent/ace/src/ace.js">');
    // Search the textarea
    Q('textarea[name="command"]').each(function(index, textarea) {
        textarea = Q(textarea);
        id = 'editor_' + index
        // Hide the original textarea
        textarea.hide();
        // Create the editor div
        textarea.after('<div id="' + id + '"/>');
        // Setup the editor
        var editor = ace.edit(id);
        editor.setOptions({
            maxLines: Infinity,
            minLines: 5,
        });
        editor.getSession().setMode('ace/mode/sh');
        // Set initial value and create the event handler
        editor.getSession().setValue(textarea.val());
        editor.getSession().on('change', function() {
            textarea.val(editor.getSession().getValue());
        });
    });
});
jayatubi
  • 1,972
  • 1
  • 21
  • 51