Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

html message gadget (CKEditor ) - ignores scripts #4229

jonasz ·

${util.getCalendar().getShortYear()} is not translate to 20.
worked before.
it was useful for adding custom build list based on system.getBuildManager()

  • replies 6
  • views 1504
  • stars 0
robinshen ADMIN ·

Groovy script can be formatted incorrectly with CKEditor, and hence not recognized by script interpreter. You may disable html editor in system setting and then edit your script to remove undesired formatting characters.

jonasz ·

Thanks!
But disable html editor in system setting means disable to the whole qb instance?

robinshen ADMIN ·
jonasz ·
jonasz ·

code example for build list on dashboard:


${groovy: configuration_id = 2; number_of_builds = 10; qb_link = 'http://quickbuild.domain.com' configuration_path = system.getConfigurationManager().get(configuration_id).getPathName()
if (system.getConfiguration(configuration_path) != null) {
def build_list = '<div class="round-box build-history"><table class="records builds"><thead><tr class="headers">'

build_list += '<th class="id"><span>Id</span></th>'
build_list += '<th><span>Version</span></th>'
build_list += '<th><span>Configuration</span></th>'
build_list += '<th><span>Begin Date</span></th>'
build_list += '<th class="id"><span>Duration</span></th>'
build_list += '<th><span>Triggered By</span></th>'

build_list += '</tr></thead><tbody>'
def prev_build = system.getConfiguration(configuration_path).getLatestBuild()
def triggered_by = ''
def image = ''
def status_class = ''
def duration = ''
def i = 0
while(i<number_of_builds){
if(prev_build == null) {break;\}
if( i % 2) {
build_list += '<tr class="odd">' \}
else {
build_list += '<tr class="even">'
\}
if(prev_build.isScheduled()){
triggered_by = '<b>Scheduler</b>' \}
else{
triggered_by = prev_build.getRequester().getDisplayName()
\}
if(prev_build.isRunning()){
duration = '<b>running...</b>'
image = 'spin-ball'
status_class = 'running' \}
else{
duration = util.formatDuration(prev_build.getDuration())
switch (prev_build.getStatus()) {
case 'SUCCESSFUL':
image = 'green-ball'
status_class = 'successful'
break
case 'FAILED':
image = 'red-ball'
status_class = 'failed'
break
case 'RECOMMENDED':
image = 'star'
status_class = 'recommended'
break
case 'CANCELLED':
image = 'cancelled'
status_class = 'cancelled'
break
case 'TIMEOUT':
image = 'timeout'
status_class = 'timeout'
break
default:
result = 'green-ball'
status_class = 'successful'
\}
\}
build_list += '<td class="id"><span>' + prev_build.getId() + '</span></td>'
build_list += '<td><span><div class="build-info"><img src="' + qb_link + '/images/' + image + '.gif">&nbsp;&nbsp;<a href="' + qb_link + '/build/' + prev_build.getId() + '" target="new" class="build-status ' + status_class + ' maskable">' + prev_build.getVersion() +'</a></div></span></td>'
build_list += '<td><span><a href="' + qb_link + '/' + configuration_id + '" target="new">' + configuration_path + '</a></span></td>'
build_list += '<td class="id"><span>' + util.formatDate(prev_build.getBeginDate()) + '</span></td>'
build_list += '<td><span>' + duration +'</span></td>'
build_list += '<td><span>' + triggered_by + '</span></td></tr>'

prev_build = system.getBuildManager().getPrevious(prev_build)
i = i+1
\}
build_list += '</tbody></table></div>'

build_list
\}
}
robinshen ADMIN ·

Thanks for the feedback