-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
名前、説明、ステータス、ビルドの状況が表示できるように ビルドを実行できるように
- Loading branch information
toshiyuki.ando1971
committed
May 13, 2009
1 parent
320bfc6
commit 9b15af1
Showing
10 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
= hudson | ||
|
||
Description goes here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# To change this template, choose Tools | Templates | ||
# and open the template in the editor. | ||
|
||
require "rexml/document" | ||
require 'open-uri' | ||
|
||
RAILS_DEFAULT_LOGGER.info 'Starting Hudson plugin for RedMine' | ||
|
||
class HudsonController < ApplicationController | ||
unloadable | ||
layout 'base' | ||
|
||
before_filter :find_project | ||
before_filter :authorize | ||
|
||
def index | ||
api_url = "http://192.168.0.51:8080/api/xml?depth=2" | ||
begin | ||
content = '' | ||
# Open the feed and parse it | ||
open(api_url) do |s| content = s.read end | ||
doc = REXML::Document.new content | ||
if doc != nil | ||
@builds = [] | ||
doc.elements.each("hudson/job") do |element| | ||
build = {} | ||
build[:name] = element.get_text("name").value | ||
build[:description] = element.get_text("description").value if element.get_text("description") != nil | ||
build[:url] = element.get_text("url").value if element.get_text("url") != nil | ||
build[:state] = element.get_text("color").value if element.get_text("color") != nil | ||
|
||
build[:healthReport] = {} | ||
build[:healthReport][:description] = element.get_text("healthReport/description").value if element.get_text("healthReport/description") != nil | ||
build[:healthReport][:score] = element.get_text("healthReport/score").value if element.get_text("healthReport/score") != nil | ||
|
||
build[:latestBuild] = {} | ||
if (element.elements["build"] != nil) | ||
build[:latestBuild][:number] = element.elements["build"].get_text("number").value | ||
build[:latestBuild][:result] = element.elements["build"].get_text("result").value | ||
build[:latestBuild][:timestamp] = Time.at( element.elements["build"].get_text("timestamp").value.to_f / 1000 ) | ||
end | ||
|
||
@builds << build | ||
end | ||
else | ||
flash.now[:error] = 'Invalid RSS feed.' unless @builds | ||
end | ||
rescue SocketError | ||
flash.now[:error] = 'Unable to connect to remote host.' | ||
end | ||
end | ||
|
||
def build | ||
raise 'no job' if params[:name] == nil | ||
|
||
build_url = "http://192.168.0.51:8080/job/#{params[:name]}/build" | ||
|
||
content = "" | ||
open(build_url) do |s| content = s.read end | ||
p "info --> #{content}" | ||
|
||
rescue | ||
render :text => "#{params[:name]} #{l(:build_failed)}" | ||
else | ||
render :text => "#{params[:name]} #{l(:build_accepted)}" | ||
end | ||
|
||
private | ||
def find_project | ||
@project = Project.find(params[:id]) | ||
rescue ActiveRecord::RecordNotFound | ||
render_404 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<%# $Id$ | ||
# To change this template, choose Tools | Templates | ||
# and open the template in the editor. | ||
%> | ||
|
||
<div class="flash notice" id="info" style="display:none;">build accepted</div> | ||
<div class="flash error" id="error" style="display:none;">build failure</div> | ||
<div id="remote-debug" style="display:none;"></div> | ||
|
||
<% @builds.each do |item|%> | ||
<div class="contextual"> | ||
<%= link_to_remote_if_authorized '[Build Now]', | ||
:url => {:action => 'build', :id => @project, :name => item[:name]}, | ||
:update => {:success => 'remote-debug', :failure => 'remote-debug'}, | ||
:success => "if(request.responseText.indexOf('build_accepted') > 0 ){Element.show('info');Element.hide('error');}else{Element.show('error');Element.hide('info');}", | ||
:failure => "Element.show('error');Element.hide('info');" | ||
%> | ||
</div> | ||
|
||
<h2 class="icon icon-<%=item[:state]%>"><%=link_to item[:name], item[:url]%></h2> | ||
|
||
<p><%=item[:healthReport][:description]%> <%=item[:healthReport][:score]%>%</p> | ||
|
||
<fieldset class="latest-build"><legend><%=l(:label_latest_build)%></legend> | ||
#<%=item[:latestBuild][:number]%> <span class="<%="result #{item[:latestBuild][:result].downcase}"%>"><%=item[:latestBuild][:result]%></span> <%=item[:latestBuild][:timestamp].strftime("%Y/%m/%d %H:%M:%S")%> | ||
</fieldset> | ||
|
||
<div class="wiki"> | ||
<%= textilizable item[:description] -%> | ||
</div> | ||
<% end %> | ||
<% content_for :header_tags do %> | ||
<%= stylesheet_link_tag "hudson.css", :plugin => "redmine_hudson", :media => "screen" %> | ||
<% end %> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
.icon-blue { background-image: url(/plugin_assets/redmine_hudson/images/blue.png); } | ||
|
||
.icon-red { background-image: url(/plugin_assets/redmine_hudson/images/red.png); } | ||
|
||
.result.failure {color:red;} | ||
|
||
.result.success {color:blue;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# $Id$ | ||
require 'redmine' | ||
|
||
Redmine::Plugin.register :redmine_hudson do | ||
name 'Redmine Hudson plugin' | ||
author 'Toshiyuki Ando' | ||
description 'This is a Hudson plugin for Redmine' | ||
version '0.1.0' | ||
|
||
project_module :hudson do | ||
# パーミッション設定。 | ||
permission :show_hudson_jobs, {:hudson => [:index]} | ||
permission :build_hudson_jobs, {:hudson => [:build]}, :require => :member | ||
end | ||
|
||
menu :project_menu, :hudson, { :controller => :hudson, :action => :index }, :param => :id, :caption => :label_hudson | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# $Id$ | ||
# English strings go here | ||
label_hudson: Hudson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# $Id$ | ||
# Japanise strings go here | ||
label_hudson: Hudson | ||
label_latest_build: 最新のビルド |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Load the normal Rails helper | ||
require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper') | ||
|
||
# Ensure that we are using the temporary fixture path | ||
Engines::Testing.set_fixture_path |