addr = Utils.parse_server_addr(option[:domain])
if addr.nil? then
- log.puts "Server address is incorrect. (#{option[:domain]})"
- log.puts "Tune as following format."
- log.puts " <ip>:<port>"
+ puts "Server address is incorrect. (#{option[:domain]})"
+ puts "Tune as following format."
+ puts " <ip>:<port>"
exit 1
end
client = BuildCommClient.create( addr[0], addr[1], nil, 0 )
if client.nil? then
- log.puts "Connection to server failed!"
- return nil
+ raise RuntimeError, "The output file is already exist."
end
client.send "LOG|#{option[:job].strip}"
end
if not result then
- log.puts "ERROR: Communication failed! #{client.get_error_msg()}"
+ puts "ERROR: Communication failed! #{client.get_error_msg()}"
client.terminate
+ log.close
+ if not output.nil? then
+ FileUtils.rm output
+ end
exit 1
else
client.terminate
if (project_list.length > 1) or (not (project_list[0].nil? or project_list[0].empty?))
# execute build command
begin
- Utils.sbi_build_command(dist_name, project_list, os_list, password_list, get_user_email)
+ result, job_id, msg = Utils.sbi_build_command(dist_name, project_list, os_list, password_list, get_user_email)
+ if result then
+ render :json => { :result => "SUCCESS", :job_id => job_id }
+ else
+ render :json => { :result => "ERROR", :message => msg }
+ end
rescue => e
render :text => e.message, :status => 406
- return
end
-
- render :json => { :success => "OK!" }
else
render :text => "Can't build project", :status => 406
end
class Utils < ApplicationController
def Utils.sbi_build_command(distribution, project_list, os_list, password_list, email)
+ job_id = nil
dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""])
if dibs_config.nil?
raise RuntimeError, "Can't find server port information"
puts "Build command"
puts "[[[#{cmd}]]]"
- return execute_shell_return(cmd)
+ result, msg = execute_shell_return(cmd)
+ msg.each { |line|
+ if line =~ /Info: Added new job "([0-9][0-9]*)" for.*/ then
+ job_id = $1
+ end
+ }
+ return result, job_id, msg
end
def Utils.sbi_register_command(distribution, file_path, password, email)
end
def Utils.execute_shell_return(cmd)
+ result = false
result_lines = []
- ret = false
# get result
- #IO.popen("#{cmd}")
- system "#{cmd}"
+ IO.popen("#{cmd} 2>&1") do |io|
+ io.each do |line|
+ result_lines.push line
+ end
+ end
+
+ if $? == 0 then
+ result = true
+ end
- return true
+ return result, result_lines
end
# set static variable in WORKING_DIR, HOME
}
}
- buildProject(buildProjectList, function () {
- $.mobile.changePage("#jobs");
+ buildProject(buildProjectList, function (json) {
+ if(json.result != "SUCCESS") {
+ if(json.error != "") {
+ alert(json.message);
+ }
+ else {
+ alert("Build request fail!");
+ }
+ }
+ else {
+ $.mobile.changePage("#jobs");
+ }
});
}
$('.projects-project-list-collapsible').collapsible();
$('.projects-project-list-listview').listview();
+
});
}
h2.innerHTML = '<span class="alignleft">'+name+'</span><span class="alignright">'+type+'</span>';
div.appendChild(h2);
- var testDiv = document.createElement('div');
- //testDiv.innerHTML = '<label><input type="checkbox" name="checkbox-mini-0" class="custom" data-mini="true" />Build</label>';
- testDiv.innerHTML = '<div data-role="fieldcontain"><fieldset data-role="controlgroup" data-type="horizontal"><legend>Font styling:</legend><input type="checkbox" name="checkbox-6" id="checkbox-6" class="custom" /><label for="checkbox-6">b</label></fieldset></div>';
- h2.appendChild(testDiv);
- $('#checkbox-6').checkboxradio();
-
var infoLine = document.createElement('p');
infoLine.setAttribute('style', 'font-size: 12px');
infoLine.innerHTML = "Maintainer : "+maintainer+"<br><br>";