Skip to content

Instantly share code, notes, and snippets.

@yesil
Created February 26, 2013 15:22
Show Gist options
  • Save yesil/5039236 to your computer and use it in GitHub Desktop.
Save yesil/5039236 to your computer and use it in GitHub Desktop.
This script creates a nice code editor thanks to the beautiful ace library for the groovy command in jenkins job configurations. The files mode-groovy.js theme-textmate.js should be in the directory jenkins/userContent The ace library itself can be set in the javascript console. This script is tested only with chrome.
ace.config.set("modePath", "/userContent");
ace.config.set("themePath", "/userContent");
var groovyCommand = document.getElementsByName("groovy.command")[0];
groovyCommand.setStyle('position:absolute;top:-10000px;left;-10000px;');
var editor = document.createElement('div');
editor.setAttribute('id','editor');
editor.setStyle('position:relative; width:100%; min-height:500px;');
editor.textContent = groovyCommand.textContent;
groovyCommand.parentElement.insertBefore(editor, groovyCommand);
var aceEditor = ace.edit("editor");
aceEditor.setTheme("ace/theme/textmate");
aceEditor.getSession().setMode("ace/mode/groovy");
aceEditor.getSession().on('change', function(){
groovyCommand.textContent = aceEditor.getSession().getValue();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment