option = option_parse
rescue => e
puts e.message
- exit 0
+ exit 1
end
begin
case option[:cmd]
when "build"
- result = Utils.parse_server_addr(option[:domain])
- if result.nil? then
+ client = nil
+ result = false
+ job_id = nil
+ job_status = ""
+ job_error = ""
+
+ addr = Utils.parse_server_addr(option[:domain])
+ if addr.nil? then
puts "Server address is incorrect. (#{option[:domain]})"
puts "Tune as following format."
puts " <ip>:<port>"
exit 1
end
- client = BuildCommClient.create( result[0], result[1], nil, 0 )
- if not client.nil? then
- client.send "BUILD|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:noreverse]}|#{option[:dist]}|#{option[:user]}|#{option[:verbose]}"
- if not client.print_stream then
- puts "ERROR: #{client.get_error_msg()}"
+
+ # Request build
+ begin
+ client = BuildCommClient.create( addr[0], addr[1], nil, 0 )
+ if client.nil? then
+ puts "Connection to server failed!"
+ exit 1
+ end
+
+ cmd = "BUILD|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:noreverse]}|#{option[:dist]}|#{option[:user]}|#{option[:rebuild]}"
+
+ client.send(cmd)
+
+ result = client.read_lines do |line|
+ if line.strip.start_with?("=JOB_START") then
+ job_id = line.strip.split(",")[1]
+ next
+ elsif line.strip.start_with?("=JOB_STATUS") then
+ data = line.strip.split(",")
+ job_status = data[1]
+ job_error = data[2]
+ next
+ end
+ # print log
+ puts line
end
+ if not result then
+ puts "Error: Communication failed! #{client.get_error_msg()}"
+ elsif job_id.nil? then
+ puts job_error
+ result = false
+ end
client.terminate
- else
- puts "Connection to server failed!"
+ rescue => e
+ puts "ERROR: #{e}"
+ client.terminate
+ end
+
+ # Query log in case sync
+ if result and option[:async].eql? "NO" then
+ begin
+ client = BuildCommClient.create( addr[0], addr[1], nil, 0 )
+ if client.nil? then
+ puts "ERROR: Can't query log, Connection to server failed!"
+ exit 1
+ end
+
+ client.send "LOG|#{job_id}"
+ result = client.read_lines do |line|
+ if line.strip.start_with?("=JOB_STATUS") then
+ data = line.strip.split(",")
+ job_status = data[1]
+ job_error = data[2]
+ next
+ end
+ # print log
+ puts line
+ end
+
+ if not result then
+ puts "ERROR: Can't query log, Communication failed! #{client.get_error_msg()}"
+ end
+
+ # Check job status
+ if not job_status.eql? "FINISHED" then
+ result = false
+ end
+ client.terminate
+ rescue => e
+ puts "ERROR: #{e}"
+ client.terminate
+ end
+ end
+
+ if not result then
exit 1
end
+
# when "resolve"
# result = Utils.parse_server_addr(option[:domain])
# if result.nil? then
query_job_list( result[0], result[1] )
when "query-log"
- result = Utils.parse_server_addr(option[:domain])
- if result.nil? then
- puts "Server address is incorrect. (#{option[:domain]})"
- puts "Tune as following format."
- puts " <ip>:<port>"
+ output = option[:output]
+ if output.nil? then
+ log = STDOUT
+ else
+ if File.exist? output
+ raise RuntimeError, "The output file is already exist."
+ end
+ log = File.open(output, "w")
+ end
+
+ 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>"
exit 1
end
- client = BuildCommClient.create( result[0], result[1], nil, 0 )
+ client = BuildCommClient.create( addr[0], addr[1], nil, 0 )
if client.nil? then
- puts "Connection to server failed!"
+ log.puts "Connection to server failed!"
return nil
end
+
client.send "LOG|#{option[:job].strip}"
- client.read_lines do |line|
+ result = client.read_lines do |line|
+ if line.strip.start_with?("=JOB_STATUS") then
+ data = line.strip.split(",")
+ job_status = data[1]
+ job_error = data[2]
+ next
+ end
+ # print log
puts line
end
- client.terminate
+
+ if not result then
+ log.puts "ERROR: Communication failed! #{client.get_error_msg()}"
+ client.terminate
+ exit 1
+ else
+ client.terminate
+ end
when "cancel"
result = Utils.parse_server_addr(option[:domain])
project_list = Project.find_by_sql("SELECT projects.id
, projects.name
, projects.ptype
+ , projects.status
FROM projects
, distributions
WHERE distributions.name = \"#{dist_name}\"
doc.Project {
doc.ProjectName(project.name)
doc.Type(project.ptype)
+ doc.ProjectStatus(project.status)
os_list = ProjectOs.find_by_sql("SELECT supported_os.name AS name
FROM project_os
project_type = change_item[:ProjectType].upcase
project_dist_name = change_item[:Distribution]
project_password = change_item[:ProjectPass]
+ project_status = change_item[:ProjectStatus].upcase
if project_name.nil? or project_name.empty? then
errmsg = "Can't find [Name] information"
return
end
+ if not project_status.eql? "OPEN" and not project_status.eql? "CLOSE"
+ errmsg = "project status is invalid"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
+
distribution = Distribution.find(:first, :conditions => ["name = ?", project_dist_name])
project = Project.find(:first, :conditions => ["name = ? and distribution_id = ? and ptype = ?", project_name, distribution.id, project_type])
project = Project.new
project.name = project_name
project.ptype = project_type
+ project.status = project_status
project.password = project_password
project.distribution_id = distribution.id
#TODO: set project user is admin. admin user id is '1'
dist_name = change_item[:Distribution]
old_project_name = change_item[:Name]
project_type = change_item[:ProjectType].upcase
+ project_status = change_item[:ProjectStatus].upcase
if old_project_name.nil? or old_project_name.empty? then
errmsg = "Can't find [#{old_project_name}] information"
return
end
+ if not project_status.eql? "OPEN" and not project_status.eql? "CLOSE"
+ errmsg = "project status is invalid"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
+
distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name])
project = Project.find(:first, :conditions => ["name = ? and distribution_id = ? and ptype = ?", old_project_name, distribution.id, project_type])
project.name = change_item[:NewProjectName]
project.password = change_item[:ProjectPass]
+ project.status = project_status
# remove project os and reset project os
ProjectOs.delete_all(["project_id = ?", project.id])
project.save
render :json => { :success => "OK!" }
end
+
+ def changeAllProjectStatus
+ change_group_list = params[:ChangeInfoList]
+ change_item = change_group_list[0]
+ errmsg = ""
+
+ dist_name = change_item[:Distribution]
+ projectStatus = change_item[:ProjectStatus]
+
+ if projectStatus.nil? or not (projectStatus.eql? "OPEN" or projectStatus.eql? "CLOSE") then
+ errmsg = "project status must be OPEN or CLOSE"
+ render :json => { :error => errmsg }, :status => 406
+ return
+ end
+
+ distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name])
+ Project.update_all("status=\"#{projectStatus}\"", :distribution_id => distribution.id)
+
+ render :json => { :success => "OK!" }
+ end
end
end
def log_more
- @cursor = nil
- @file = nil
-
line_cnt = 999
conti= 1
id = params[:id]
end
# Get log file infomation
- file_name = "log"
- buildsvr_path = Server_config.find(:first, :conditions => ["property = ?", "path"])
- directory = "#{buildsvr_path.value}/jobs/#{id}"
-
- # create the file path
- path = File.join(directory, file_name)
-
- # read the file
- if File.exist?(path)
- @cursor = File.size(path)
- @file = File.open(path, 'r')
- data = @file.readlines
- end
+ server_id = Server_config.find(:first, :conditions => ["property = \"id\""])
+ path = File.join(Utils::DIBS_WEB_CONFIG_PATH, server_id.value, "#{id}.log")
time = Time.new
timestamp = time.getlocal
- start_line = line
- last_line = start_line + line_cnt
-
- #count line
- tok = nil
- IO.popen("wc -l #{path}") do |wc|
- tok = wc.read.split(" ")
- end
- end_line = tok[0].to_i
-
- #check line
- if last_line > end_line
- last_line = end_line
- end
+ #check file exist
+ if not File.exist?(path) then
+ #if file does not exist then execute query-log command
+ Utils.sbi_query_log_command(id)
+ conti = 1
+ else
+ start_line = line
+ last_line = start_line + line_cnt
+
+ #count line
+ tok = nil
+ IO.popen("wc -l #{path}") do |wc|
+ tok = wc.read.split(" ")
+ end
+ end_line = tok[0].to_i
+
+ #check line
+ if last_line > end_line
+ last_line = end_line
+ end
- #read log file
- temp = nil
- if start_line < end_line
- IO.popen("sed -n \"#{start_line},#{last_line}p\" #{path}") do |sed|
- temp = sed.read
+ #read log file
+ log_contents = nil
+ if start_line < end_line
+ IO.popen("sed -n \"#{start_line},#{last_line}p\" #{path}") do |sed|
+ log_contents = sed.read
+ end
+ else
+ last_line_content = IO.readlines(path)[-1]
+ puts "!!!!!!!!!!!!!!!!!!"
+ puts path
+
+
+ puts IO.readlines(path)
+ puts "!!!!!!!!!!!!!!!!!!"
+ if last_line_content.start_with?("=STATUS,") then
+ if start_line = 1 then log_contents = [last_line_content] end
+ conti = 0
+ elsif job.status.eql? "FINISHED" or job.status.eql? "CANCELED" or job.status.eql? "ERROR" then
+ if start_line = 1 then log_contents = [last_line_content] end
+ conti = 0
+ end
end
- else
- conti= 0
end
#generate to XML
doc.Status(job.status)
doc.Time(timestamp)
doc.Continue(conti)
- if temp
- temp.each do |data|
+ if log_contents
+ log_contents.each do |data|
doc.LogData(data, "Line" => line)
line = line + 1
end
doc.supportedOs(os.name)
end
end
+ doc.DistributionStatus(distribution.status)
}
projects.each do |project|
if checkUserAccessProject(user_id, project.id)
doc.BinaryProject {
doc.ProjectName(project.name)
+ doc.ProjectStatus(project.status)
if not bin.nil? then
doc.PackageName(bin.pkg_name)
end
else
doc.OtherBinaryProject {
doc.ProjectName(project.name)
+ doc.ProjectStatus(project.status)
if not bin.nil? then
doc.PackageName(bin.pkg_name)
end
if checkUserAccessProject(user_id, project.id)
doc.Project {
doc.ProjectName(project.name)
+ doc.ProjectStatus(project.status)
doc.OsList(buildOsNameList.join(","))
}
else
doc.OtherProject {
doc.ProjectName(project.name)
+ doc.ProjectStatus(project.status)
doc.OsList(buildOsNameList.join(","))
}
end
# constant
BUILD_SERVER_ADDRESS = "127.0.0.1"
+DIBS_PATH = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
class Utils < ApplicationController
def Utils.sbi_build_command(distribution, project_list, os_list, password_list, email)
- dibs_path = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""])
if dibs_config.nil?
- raise RuntimeError, "Build sever not started"
+ raise RuntimeError, "Can't find server port information"
else
dibs_address = BUILD_SERVER_ADDRESS + ":" + dibs_config.value
end
options = options + " -U #{email} "
end
- cmd = "#{dibs_path}/build-cli build #{options}"
+ cmd = "#{DIBS_PATH}/build-cli build #{options}"
puts "Build command"
puts "[[[#{cmd}]]]"
end
def Utils.sbi_register_command(distribution, file_path, password, email)
- dibs_path = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""])
if dibs_config.nil?
- raise RuntimeError, "Build sever not started"
+ raise RuntimeError, "Can't find server port information"
else
dibs_address = BUILD_SERVER_ADDRESS + ":" + dibs_config.value
end
options = options + " -U #{email} "
end
- cmd = "#{dibs_path}/build-cli register #{options}"
+ cmd = "#{DIBS_PATH}/build-cli register #{options}"
puts "Register command"
puts "[[[#{cmd}]]]"
return execute_shell_return(cmd)
end
def Utils.sbi_cancel_command(job_id, password)
- dibs_path = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""])
if dibs_config.nil?
- raise RuntimeError, "Build sever not started"
+ raise RuntimeError, "Can't find server port information"
else
dibs_address = BUILD_SERVER_ADDRESS + ":" + dibs_config.value
end
options = options + " -w #{password}"
end
- cmd = "#{dibs_path}/build-cli cancel #{options}"
+ cmd = "#{DIBS_PATH}/build-cli cancel #{options}"
puts "Cancel command"
puts "[[[#{cmd}]]]"
return execute_shell_return(cmd)
end
def Utils.sbi_fullbuild_command(server_name, dist_name)
- dibs_path = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
-
options = "-n #{server_name} --dist #{dist_name} "
- cmd = "#{dibs_path}/build-svr fullbuild #{options}"
+ cmd = "#{DIBS_PATH}/build-svr fullbuild #{options}"
cmd = "which ruby"
puts "Fullbuild command"
puts "[[[#{cmd}]]]"
return execute_shell_return(cmd)
end
+ def Utils.sbi_query_log_command(job_id)
+ dibs_web_config_path = File.join(Utils::HOME,".build_tools","web_server")
+ dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""])
+ if dibs_config.nil?
+ raise RuntimeError, "Can't find server port information"
+ else
+ dibs_address = BUILD_SERVER_ADDRESS + ":" + dibs_config.value
+ end
+
+ dibs_config = Server_config.find(:first, :conditions => ["property = \"id\""])
+ if dibs_config.nil?
+ raise RuntimeError, "Can't find build server id"
+ else
+ path = File.join(dibs_web_config_path, dibs_config.value, "#{job_id}.log")
+ end
+
+ if job_id.nil? or path.nil? then
+ raise RuntimeError, "Invalid query command id : #{job_id} path : #{path}"
+ end
+
+ options = "-d #{dibs_address} "
+ options = options + " -j #{job_id}"
+ options = options + " --output #{path}"
+
+ cmd = "#{DIBS_PATH}/build-cli query-log #{options}"
+
+ fork do
+ exec(cmd)
+ end
+
+ return path
+ end
+
def Utils.execute_shell_return(cmd)
result_lines = []
ret = false
return true
end
+ # set static variable in WORKING_DIR, HOME
+ if defined?(WORKING_DIR).nil? then WORKING_DIR = Dir.pwd end
+ if defined?(HOME).nil? then
+ # get home directory, using Dir.chdir
+ Dir.chdir
+ HOME = Dir.pwd
+ Dir.chdir WORKING_DIR
+ end
+ DIBS_WEB_CONFIG_PATH = File.join(HOME,".build_tools","web_server")
end
class Project < ActiveRecord::Base
- attr_accessible :id, :distribution_id, :name, :ptype, :password
+ attr_accessible :id, :distribution_id, :name, :ptype, :password, :status
end
get "jobs/list/date/:date/:distribution/:status/:lastID" => "jobs#listSearchDate", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ }
match "jobs/update" => "jobs#updateList", :format => "json"
- match "jobs/log/:id" => "jobs#log"
match "jobs/log/:id/:line" => "jobs#log_more"
match "jobs/cancel/:id" => "jobs#cancelJob"
post "admin_project/addProject"
post "admin_project/removeProject"
post "admin_project/modifyProject"
+ post "admin_project/changeAllProjectStatus"
# admin distribution
match "admin_distribution/queryDistributionInfo/:distribution" => "admin_distribution#queryDistributionInfo", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ }
</select>
</div>
</div>
+ <div id="build-distribution-lock"> </div>
<div data-role="collapsible" data-collapsed="false" style="width: auto;" >
<h3>Git project</h3>
<div align="right" style="font-size: 10px">
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=#adminUser onClick="adminUserModify()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href=#adminUser onClick="adminUserModify()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
<div class="content-primary">
<h2>Group information</h2>
<div align="right" style="font-size: 10px">
- <a href="#adminGroupAdd" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add group </a>
+ <a href="#adminGroupAdd" data-role="button" data-rel="dialog" data-inline="true" data-mini="ture" data-icon="plus"> Add group </a>
</div>
<div data-role="content" class="container">
<table class="imagetable" style="font-size: 14px" id="adminGroup-contents">
<div class="content-primary">
<h2>Server information</h2>
<div align="right" style="font-size: 10px">
- <a href="#adminServerAddServerInfo" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add server config </a>
+ <a href="#adminServerAddServerInfo" data-role="button" data-rel="dialog" data-inline="true" data-mini="ture" data-icon="plus"> Add server config </a>
</div>
<div data-role="collapsible" data-theme="c" data-content-theme="d" data-collapsed="false">
<h2> Server info </h2>
</ul>
</div>
<div align="right" style="font-size: 10px">
- <a href="#adminServerAddSupportedOs" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add supported os</a>
- <a href="#adminServerAddOSCategory" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add os category</a>
- <a href="#adminServerRemoveOSCategory" data-role="button" data-rel="dialog" data-inline="true" data-icon="minus"> Remove os category</a>
+ <a href="#adminServerAddSupportedOs" data-role="button" data-rel="dialog" data-inline="true" data-mini="ture" data-icon="plus"> Add supported os</a>
+ <a href="#adminServerAddOSCategory" data-role="button" data-rel="dialog" data-inline="true" data-mini="ture" data-icon="plus"> Add os category</a>
+ <a href="#adminServerRemoveOSCategory" data-role="button" data-rel="dialog" data-inline="true" data-mini="ture" data-icon="minus"> Remove os category</a>
</div>
<div data-role="collapsible" data-theme="c" data-content-theme="d" data-collapsed="false">
<h2> Supported OS </h2>
</ul>
</div>
<div align="right" style="font-size: 10px">
- <a href="#adminServerAddRemoteBuildServer" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add remote build server </a>
+ <a href="#adminServerAddRemoteBuildServer" data-role="button" data-rel="dialog" data-inline="true" data-mini="ture" data-icon="plus"> Add remote build server </a>
</div>
<div data-role="collapsible" data-theme="c" data-content-theme="d" data-collapsed="false">
<h2> Remote build server </h2>
</div>
</div>
<div>
+ <div align="right" style="font-size: 10px">
+ <a href="#" data-role="button" data-inline="true" data-mini="true" onClick='adminProjectAllProjectStatusChange("OPEN")'>ALL project OPEN</a>
+ <a href="#" data-role="button" data-inline="true" data-mini="true" onClick='adminProjectAllProjectStatusChange("CLOSE")'>ALL project CLOSE</a>
+ </div>
<div style="margin-left: 20px; margin-right: 20px; margin-top: 10px">
<div data-role="collapsible" data-theme="b" data-content-theme="c" data-collapsed="false" >
<h2> Git project </h2>
<div align="right" style="font-size: 10px">
- <a href="#adminProjectAddGit" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add git project</a>
+ <a href="#adminProjectAddGit" data-role="button" data-rel="dialog" data-inline="true" data-mini="true" data-icon="plus"> Add git project</a>
</div>
<br>
<table class="imagetable" id="adminProject-git" style="font-size: 14px">
<div data-role="collapsible" data-theme="b" data-content-theme="c" data-collapsed="false" >
<h2> Binary project </h2>
<div align="right" style="font-size: 10px">
- <a href="#adminProjectAddBinary" data-role="button"data-rel="dialog" data-inline="true" data-icon="plus"> Add binary project</a>
+ <a href="#adminProjectAddBinary" data-role="button"data-rel="dialog" data-inline="true" data-mini="true" data-icon="plus"> Add binary project</a>
</div>
<table class="imagetable" id="adminProject-binary" style="font-size: 14px">
</table>
</select>
</div>
<div align="right" style="font-size: 10px">
- <a href="javascript:adminDistributionFullBuild()" data-role="button" data-inline="true" data-icon="gear"> Full build</a>
+ <!-- <a href="javascript:adminDistributionFullBuild()" data-role="button" data-inline="true" data-mini="true" data-icon="gear"> Full build</a> -->
</div>
<div data-role="collapsible" data-theme="c" data-content-theme="d" data-collapsed="false" >
<h2> Package server url </h2>
</div>
<br>
<div align="right" style="font-size: 10px">
- <a href="#adminDistributionAdd" data-role="button" data-rel="dialog" data-inline="true" data-icon="plus"> Add distribution</a>
- <a href="#adminDistributionModify" data-role="button" data-rel="dialog" data-inline="true" data-icon="gear"> Modify distribution</a>
- <a href="javascript:adminDistributionRemove()" data-role="button" data-rel="dialog" data-inline="true" data-icon="minus"> Remove distribution</a>
+ <a href="#adminDistributionAdd" data-role="button" data-rel="dialog" data-inline="true" data-mini="true" data-icon="plus"> Add distribution</a>
+ <a href="#adminDistributionModify" data-role="button" data-rel="dialog" data-inline="true" data-mini="true" data-icon="gear"> Modify distribution</a>
+ <a href="javascript:adminDistributionRemove()" data-role="button" data-rel="dialog" data-inline="true" data-mini="true" data-icon="minus"> Remove distribution</a>
</div>
</div>
</div><!--/content-primary -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=# onClick="adminDistributionAdd()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href=# onClick="adminDistributionAdd()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
<label for="adminProjectAddGit-branch"> Git Branch </label>
<input type="text" id="adminProjectAddGit-branch" name="branch" />
<br>
+ <label for="adminProjectAddGit-status"> Project status </label>
+ <select id="adminProjectAddGit-status" name="status" >
+ </select>
+ <br>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-mini="true" id="adminProjectAddGit-os" name="os" >
</fieldset>
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#adminProject" onClick="adminProjectAddGitProject()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#adminProject" onClick="adminProjectAddGitProject()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
<br>
<label for="adminProjectAddBinary-packagename"> Pakcage name</label>
<input type="text" id="adminProjectAddBinary-packagename" name="name" />
+ <br>
+ <label for="adminProjectAddBinary-status"> Project status </label>
+ <select id="adminProjectAddBinary-status" name="status" >
+ </select>
+ <br>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" data-mini="true" id="adminProjectAddBinary-os" name="os" >
</fieldset>
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminProjectAddBinaryProject()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminProjectAddBinaryProject()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
<label for="adminProjectModifyBinary-password"> Project password</label>
<input type="text" id="adminProjectModifyBinary-password" name="name" />
<br>
+ <label for="adminProjectModifyBinary-status"> Project status </label>
+ <select id="adminProjectModifyBinary-status" name="status" >
+ </select>
+ <br>
<label for="adminProjectModifyBinary-packageName"> Pakcage name</label>
<input type="text" id="adminProjectModifyBinary-packageName" name="name" />
<div data-role="fieldcontain">
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminProjectModfyBinaryProject()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminProjectModfyBinaryProject()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
<label for="adminProjectModifyGit-password"> Project password</label>
<input type="text" id="adminProjectModifyGit-password" name="password" />
<br>
+ <label for="adminProjectModifyGit-status"> Project status </label>
+ <select id="adminProjectModifyGit-status" name="status" >
+ </select>
+ <br>
<label for="adminProjectModifyGit-address"> Git address </label>
<input type="text" id="adminProjectModifyGit-address" name="address" />
<br>
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminProjectModfyGitProject()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminProjectModfyGitProject()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=# onClick="adminGroupAddGroup()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href=# onClick="adminGroupAddGroup()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminGroupModifyGroup()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminGroupModifyGroup()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=# onClick="adminServerAddRemoteBuildServer()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href=# onClick="adminServerAddRemoteBuildServer()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=# onClick="adminServerModifyRemoteBuildServer()" data-role="button" data-inline="true" data-icon="gear">Save</a>
- <a href=# onClick="adminServerRemoveRemoteBuildServer()" data-role="button" data-inline="true" data-icon="minus">Delete</a>
+ <a href=# onClick="adminServerModifyRemoteBuildServer()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
+ <a href=# onClick="adminServerRemoveRemoteBuildServer()" data-role="button" data-inline="true" data-mini="true" data-icon="minus">Delete</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="userModifyUserInfo()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="userModifyUserInfo()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminServerAddSupportedOs()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminServerAddSupportedOs()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminServerRemoveSupportedOS()" data-role="button" data-inline="true" data-icon="minus">Remove</a>
- <a href="#" onClick="adminServerModifySupportedOS()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminServerRemoveSupportedOS()" data-role="button" data-inline="true" data-mini="true" data-icon="minus">Remove</a>
+ <a href="#" onClick="adminServerModifySupportedOS()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminServerAddOSCategory()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href="#" onClick="adminServerAddOSCategory()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href="#" onClick="adminServerRemoveOSCategory()" data-role="button" data-inline="true" data-icon="minus">Delete</a>
+ <a href="#" onClick="adminServerRemoveOSCategory()" data-role="button" data-inline="true" data-mini="true" data-icon="minus">Delete</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=# onClick="adminServerAddServerInfo()" data-role="button" data-inline="true" data-icon="gear">Save</a>
+ <a href=# onClick="adminServerAddServerInfo()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
</div>
</div><!-- /page -->
</form>
</div>
<div align="right" style="font-size: 10px">
- <a href=# onClick="adminServerModifyServerInfo()" data-role="button" data-inline="true" data-icon="gear">Save</a>
- <a href=# onClick="adminServerRemoveServerInfo()" data-role="button" data-inline="true" data-icon="minus">Delete</a>
+ <a href=# onClick="adminServerModifyServerInfo()" data-role="button" data-inline="true" data-mini="true" data-icon="gear">Save</a>
+ <a href=# onClick="adminServerRemoveServerInfo()" data-role="button" data-inline="true" data-mini="true" data-icon="minus">Delete</a>
</div>
</div><!-- /page -->
if(serverStatusText.toUpperCase() == "CLOSE") {
option = '<option value="CLOSE" selected="selected">CLOSE</option>';
} else {
- option = '<option value="CLOSE">FALSE</option>';
+ option = '<option value="CLOSE">CLOSE</option>';
}
$("#adminDistributionModify-status").append(option);
$("#adminDistributionModify-status").selectmenu("refresh");
$("#adminProjectAddGit-password").val("");
$("#adminProjectAddGit-address").val("");
$("#adminProjectAddGit-branch").val("");
+ $("#adminProjectAddGit-status").empty();
+
+ var option;
+ option = '<option value="OPEN" selected="selected">OPEN</option>';
+ $("#adminProjectAddGit-status").append(option);
+ option = '<option value="CLOSE">CLOSE</option>';
+ $("#adminProjectAddGit-status").append(option);
+ $("#adminProjectAddGit-status").selectmenu("refresh");
queryAllOS( function (xml) {
var osList = $(xml).find("Data").find("OsName");
$("#adminProjectAddBinary-name").val("");
$("#adminProjectAddBinary-password").val("");
$("#adminProjectAddBinary-packagename").val("");
+ $("#adminProjectAddBinary-status").empty();
+
+ var option;
+ option = '<option value="OPEN" selected="selected">OPEN</option>';
+ $("#adminProjectAddBinary-status").append(option);
+ option = '<option value="CLOSE">CLOSE</option>';
+ $("#adminProjectAddBinary-status").append(option);
+ $("#adminProjectAddBinary-status").selectmenu("refresh");
queryAllOS( function (xml) {
var osList = $(xml).find("Data").find("OsName");
var password = $("#adminProjectAddGit-password").val();
var address = $("#adminProjectAddGit-address").val();
var branch = $("#adminProjectAddGit-branch").val();
+ var projectStatus = $("#adminProjectAddGit-status option:selected").val();
var selectOsList = [];
var selectArray = $("input[name='adminProjectAddGit-os-checkbox']");
return;
}
- changeInfoItem = {"Distribution":distName, "Name":name, "ProjectType":type, "ProjectPass":password, "Address":address, "Branch":branch, "OSNameList":selectOsList.toString()};
+ changeInfoItem = {"Distribution":distName, "Name":name, "ProjectType":type, "ProjectPass":password, "Address":address, "Branch":branch, "ProjectStatus":projectStatus, "OSNameList":selectOsList.toString()};
changeInfoList.push(changeInfoItem);
addProject(changeInfoList, function () {
var name = $("#adminProjectAddBinary-name").val();
var password = $("#adminProjectAddBinary-password").val();
var pkgName = $("#adminProjectAddBinary-packagename").val();
+ var projectStatus = $("#adminProjectAddBinary-status option:selected").val();
var selectOsList = [];
var selectArray = $("input[name='adminProjectAddBinary-os-checkbox']");
return;
}
- changeInfoItem = {"Distribution":distName, "Name":name, "ProjectType":type, "ProjectPass":password, "PackageName":pkgName, "OSNameList":selectOsList.toString()};
+ changeInfoItem = {"Distribution":distName, "Name":name, "ProjectType":type, "ProjectPass":password, "PackageName":pkgName, "ProjectStatus":projectStatus, "OSNameList":selectOsList.toString()};
changeInfoList.push(changeInfoItem);
addProject(changeInfoList, function () {
function adminProjectModifyBinaryProjectInit() {
var projectName = localStorage.projectName;
var packageName = $("#adminProject-binary-packageName-"+projectName).html();
+ var projectStatusText = $("#adminProject-binary-"+projectName+"-status").html();
$("#adminProjectModifyBinary-oldName").val(projectName);
$("#adminProjectModifyBinary-newName").val(projectName);
$("#adminProjectModifyBinary-password").val("");
$("#adminProjectModifyBinary-packageName").val(packageName);
+ $("#adminProjectModifyBinary-status").empty();
$("#adminProjectModifyBinary-os").empty();
$("#adminProjectModifyBinary-os").append("<legend> os list </legend>");
+ $("#adminProjectModifyBinary-status").empty();
+ var option;
+ if(projectStatusText.toUpperCase() == "OPEN") {
+ option = '<option value="OPEN" selected="selected">OPEN</option>';
+ } else {
+ option = '<option value="OPEN">OPEN</option>';
+ }
+ $("#adminProjectModifyBinary-status").append(option);
+
+ if(projectStatusText.toUpperCase() == "CLOSE") {
+ option = '<option value="CLOSE" selected="selected">CLOSE</option>';
+ } else {
+ option = '<option value="CLOSE">CLOSE</option>';
+ }
+ $("#adminProjectModifyBinary-status").append(option);
+ $("#adminProjectModifyBinary-status").selectmenu("refresh");
+
queryAllOS( function (xml) {
var osList = $(xml).find("Data").find("OsName");
var selectedOsList = [];
var projectName = localStorage.projectName;
var projectAddress = $("#adminProject-git-"+projectName+"-address").html();
var projectBranch = $("#adminProject-git-"+projectName+"-branch").html();
+ var projectStatusText = $("#adminProject-git-"+projectName+"-status").html();
$("#adminProjectModifyGit-oldName").val(projectName);
$("#adminProjectModifyGit-newName").val(projectName);
$("#adminProjectModifyGit-password").val("");
$("#adminProjectModifyGit-address").val(projectAddress);
$("#adminProjectModifyGit-branch").val(projectBranch);
+ $("#adminProjectModifyGit-status").empty();
$("#adminProjectModifyGit-os").empty();
$("#adminProjectModifyGit-os").append("<legend> os list </legend>");
+ var option;
+ if(projectStatusText.toUpperCase() == "OPEN") {
+ option = '<option value="OPEN" selected="selected">OPEN</option>';
+ } else {
+ option = '<option value="OPEN">OPEN</option>';
+ }
+ $("#adminProjectModifyGit-status").append(option);
+
+ if(projectStatusText.toUpperCase() == "CLOSE") {
+ option = '<option value="CLOSE" selected="selected">CLOSE</option>';
+ } else {
+ option = '<option value="CLOSE">CLOSE</option>';
+ }
+ $("#adminProjectModifyGit-status").append(option);
+ $("#adminProjectModifyGit-status").selectmenu("refresh");
queryAllOS( function (xml) {
var osList = $(xml).find("Data").find("OsName");
var oldProjectName = $("#adminProjectModifyBinary-oldName").val();
var newProjectName = $("#adminProjectModifyBinary-newName").val();
var projectPassword = $("#adminProjectModifyBinary-password").val();
+ var projectStatus = $("#adminProjectModifyBinary-status option:selected").val();
var packageName = $("#adminProjectModifyBinary-packageName").val();
var selectOsList = [];
return;
}
- changeInfoItem = {"Distribution":distName, "Name":oldProjectName, "NewProjectName":newProjectName, "ProjectType":"BINARY", "ProjectPass":projectPassword, "PackageName":packageName, "OSNameList":selectOsList.toString()};
+ changeInfoItem = {"Distribution":distName, "Name":oldProjectName, "NewProjectName":newProjectName, "ProjectType":"BINARY", "ProjectPass":projectPassword, "ProjectStatus":projectStatus, "PackageName":packageName, "OSNameList":selectOsList.toString()};
changeInfoList.push(changeInfoItem);
modifyProject(changeInfoList, function () {
var projectPassword = $("#adminProjectModifyGit-password").val();
var projectAddress = $("#adminProjectModifyGit-address").val();
var projectBranch = $("#adminProjectModifyGit-branch").val();
+ var projectStatus = $("#adminProjectModifyGit-status option:selected").val();
var selectOsList = [];
var selectArray = $("input[name='adminProjectModifyGit-os-checkbox']");
return;
}
- changeInfoItem = {"Distribution":distName, "Name":oldProjectName, "NewProjectName":newProjectName, "ProjectType":"GIT", "ProjectPass":projectPassword, "ProjectAddress":projectAddress, "ProjectBranch":projectBranch, "OSNameList":selectOsList.toString()};
+ changeInfoItem = {"Distribution":distName, "Name":oldProjectName, "NewProjectName":newProjectName, "ProjectType":"GIT", "ProjectPass":projectPassword, "ProjectAddress":projectAddress, "ProjectBranch":projectBranch, "ProjectStatus":projectStatus, "OSNameList":selectOsList.toString()};
changeInfoList.push(changeInfoItem);
modifyProject(changeInfoList, function () {
$("#adminProject-binary").empty();
// Project table header
- var tableHeader = "<tr><th>Project</th><th>Git repos</th><th>Branch</th><th>OS list</th><th>Modify</th><th>Delete</th>";
+ var tableHeader = "<tr><th>Project</th><th>Git repos</th><th>Branch</th><th>OS list</th><th>Status</th><th>Modify</th><th>Delete</th>";
$("#adminProject-git").append(tableHeader);
// Binary project table header
- var tableHeader = "<tr><th>Project</th><th>Package name</th><th>OS list</th><th>Modify</th><th>Delete</th>";
+ var tableHeader = "<tr><th>Project</th><th>Package name</th><th>OS list</th><th>Status</th><th>Modify</th><th>Delete</th>";
+
$("#adminProject-binary").append(tableHeader);
var projectIdx = 1;
projectList.each(function(){
var name = $(this).find("ProjectName").text();
var type = $(this).find("Type").text();
+ var project_status = $(this).find("ProjectStatus").text();
var osList = $(this).find("OS");
if(type.toUpperCase() == "GIT")
div = adminProjectApendOsCell(osList, name, "GIT");
cell.appendChild(div);
+ cell = row.insertCell(-1);
+ cell.setAttribute('id',"adminProject-git-"+name+"-status");
+ cell.innerHTML = project_status;
+
cell = row.insertCell(-1);
var button = document.createElement('a');
button.setAttribute('href','#adminProjectModifyGit');
cell = row.insertCell(-1);
var button = document.createElement('input');
button.setAttribute('type','button');
- button.setAttribute('id','button:git:'+projectIdx+':'+name);
button.setAttribute('data-mini','true');
button.setAttribute('name',name);
button.setAttribute('class','binaryProjectTableButton');
div = adminProjectApendOsCell(osList, name, "BINARY");
cell.appendChild(div);
+ cell = row.insertCell(-1);
+ cell.setAttribute('id',"adminProject-binary-"+name+"-status");
+ cell.innerHTML = project_status;
+
cell = row.insertCell(-1);
var button = document.createElement('a');
button.setAttribute('href','#adminProjectModifyBinary');
return div;
}
+function adminProjectAllProjectStatusChange(projectStatus) {
+ var distName = $("#adminProject-distribution-select option:selected").val();
+ var changeInfoList = [];
+ var changeInfoItem;
+
+ var r=confirm("All project status is changed to "+projectStatus+"!!!");
+ if (r==false)
+ {
+ return;
+ }
+ changeInfoItem = {"Distribution":distName, "ProjectStatus":projectStatus}
+ changeInfoList.push(changeInfoItem);
+
+ changeAllProjectStatus(changeInfoList, function () {
+ $.mobile.changePage("#adminProject");
+ });
+}
button.setAttribute('href','#adminUserModify');
button.setAttribute('data-role','button');
button.setAttribute('data-rel','dialog');
+ button.setAttribute('data-mini','ture');
button.setAttribute('class','adminUser-contentsButton');
button.setAttribute('onClick','adminUserModifySetup('+userId+')');
button.innerHTML = " "
var button = document.createElement('input');
button.setAttribute('type','button');
button.setAttribute('name',email);
+ button.setAttribute('data-mini','ture');
button.setAttribute('class','adminUser-contentsButton');
button.setAttribute('onClick','adminUserRemoveUser('+userId+')');
cell.appendChild(button);
$("#build-binary-table").empty();
var xmlBody = $(xml).find("Data");
+ var distributionStatus = xmlBody.find("BuildServerInfo").find("DistributionStatus").text();
+ if (distributionStatus == "CLOSE") {
+ var distributionLock = document.getElementById("build-distribution-lock");
+ distributionLock.innerHTML = '<p> Distribution is locked </p>';
+ } else {
+ var distributionLock = document.getElementById("build-distribution-lock");
+ distributionLock.innerHTML = '';
+ }
+
buildAddTableRow( xmlBody.find("BuildServerInfo").find("supportedOs"),
+ distributionStatus,
xmlBody.find("Project"),
xmlBody.find("OtherProject"));
- buildAddBinaryTableRow( xmlBody.find("BinaryProject"),
+ buildAddBinaryTableRow( distributionStatus,
+ xmlBody.find("BinaryProject"),
xmlBody.find("OtherBinaryProject"));
});
}
return false;
}
-function buildAddTableRow(supportedOs, projectList, otherProjectList) {
+function buildAddTableRow(supportedOs, distributionStatus, projectList, otherProjectList) {
// Table header
var idx = 0;
var tableHeader = "";
projectList.each(function(){
var name = $(this).find("ProjectName").text();
- var osLists = $(this).find("OsList").text();
- var osList = osLists.split(",");
+ var projectOsArray = $(this).find("OsList").text().split(",");
+ var projectStatus = $(this).find("ProjectStatus").text();
+ var buildAvailable = true;
var row = projectTable.insertRow(-1);
cell.setAttribute('bgcolor', '#dcddc0');
cell.innerHTML = name;
- for (i=0;i<osArray.length;i++)
- {
- var cell = row.insertCell(-1);
- var os = osArray[i];
-
- cell.setAttribute('id', "buildGitProjectTable"+":"+name+":"+os);
- cell.setAttribute('style', 'text-align: center');
- cell.setAttribute('bgcolor', '#dcddc0');
-
- var buttonnode = document.createElement('input');
- buttonnode.setAttribute('type','checkbox');
- buttonnode.setAttribute('id',"table"+":"+name+':'+os);
- buttonnode.setAttribute('name','projectBuildCheckbox'+":"+name);
- buttonnode.setAttribute('class','projectTableBuildButton');
- cell.appendChild(buttonnode);
-
- if(!contains(osList, os))
- {
- buttonnode.setAttribute('disabled','disabled');
- }
+ if (distributionStatus == "CLOSE" || projectStatus == "CLOSE") {
+ buildAvailable = false;
}
-
- /* append all checkbox */
- var cell = row.insertCell(-1);
- cell.setAttribute('style', 'text-align: center');
- cell.setAttribute('bgcolor', '#dcddc0');
-
- var buttonnode = document.createElement('input');
- buttonnode.setAttribute('type','checkbox');
- buttonnode.setAttribute('id','projectBuildCheckbox'+":"+name);
- buttonnode.setAttribute('name','all-checkbox');
- buttonnode.setAttribute('class','projectTableAllButton');
- buttonnode.setAttribute('onClick','buildSelectAll(this)');
- cell.appendChild(buttonnode);
+
+ buildAddBinaryTableCell(name, osArray, projectOsArray, buildAvailable, row);
});
otherProjectList.each(function(){
cell.setAttribute('bgcolor', '#c0c0c0');
cell.innerHTML = name;
- /* add empty cell for status */
- for (i=0;i<osArray.length;i++)
- {
- cell = row.insertCell(-1);
- cell.setAttribute('id', "table"+":"+name+"-"+osArray[i]);
- cell.setAttribute('style', 'text-align: left');
- cell.setAttribute('bgcolor', '#c0c0c0');
- cell.innerHTML = "";
- }
-
- /* add empty cell for all*/
- cell = row.insertCell(-1);
- cell.setAttribute('style', 'text-align: left');
- cell.setAttribute('bgcolor', '#c0c0c0');
- cell.innerHTML = "";
+ buildAddBinaryTableCell(name, osArray, "", false, row);
});
}
-function buildAddBinaryTableRow(binaryProjectList, otherProjectList) {
+function buildAddBinaryTableRow(distributionStatus, binaryProjectList, otherProjectList) {
var binaryProjectTable = document.getElementById("build-binary-table");
var row = binaryProjectTable.insertRow(-1);
var thCell = document.createElement('th');
binaryProjectList.each(function(){
var name = $(this).find("ProjectName").text();
var packageName = $(this).find("PackageName").text();
+ var projectStatus = $(this).find("ProjectStatus").text();
var row = '<tr><td bgcolor="#dcddc0" style="text-align:left">'+name+'</td>';
row += '<td bgcolor="#dcddc0" style="text-align:left">' + packageName + '</td>'
- row += '<td bgcolor="#dcddc0" style="text-align:left"><a href="upload.html" onClick="buildUploadBinaryName(\'' +name+'\')" class="binary_project_button" data-role="button" data-ajax="false" data-mini="true">REGISTER</a>';
+ if (distributionStatus == "CLOSE" || projectStatus == "CLOSE") {
+ row += '<td bgcolor="#c0c0c0" style="text-align:left"></td>';
+ } else {
+ row += '<td bgcolor="#dcddc0" style="text-align:left"><a href="upload.html" onClick="buildUploadBinaryName(\'' +name+'\')" class="binary_project_button" data-role="button" data-ajax="false" data-mini="true">REGISTER</a>';
+ }
row += '</tr>'
$("#build-binary-table tr:last").after(row);
});
}
+function buildAddBinaryTableCell(projectName, osArray, projectOsArray, buildAvailable, row) {
+ for (i=0;i<osArray.length;i++)
+ {
+ var cell = row.insertCell(-1);
+ var os = osArray[i];
+
+ cell.setAttribute('id', "buildGitProjectTable"+":"+projectName+":"+os);
+ cell.setAttribute('style', 'text-align: center');
+ if (buildAvailable) {
+ /* add cell with build checkbox */
+ cell.setAttribute('bgcolor', '#dcddc0');
+
+ var buttonnode = document.createElement('input');
+ buttonnode.setAttribute('type','checkbox');
+ buttonnode.setAttribute('id',"table"+":"+projectName+':'+os);
+ buttonnode.setAttribute('name','projectBuildCheckbox'+":"+projectName);
+ buttonnode.setAttribute('class','projectTableBuildButton');
+ cell.appendChild(buttonnode);
+
+ if(!contains(projectOsArray, os))
+ {
+ buttonnode.setAttribute('disabled','disabled');
+ }
+ } else {
+ /* add empty cell for status */
+ cell.setAttribute('bgcolor', '#c0c0c0');
+ cell.innerHTML = "";
+ }
+ }
+
+ if (buildAvailable) {
+ /* append all checkbox */
+ var cell = row.insertCell(-1);
+ cell.setAttribute('style', 'text-align: center');
+ cell.setAttribute('bgcolor', '#dcddc0');
+
+ var buttonnode = document.createElement('input');
+ buttonnode.setAttribute('type','checkbox');
+ buttonnode.setAttribute('id','projectBuildCheckbox'+":"+projectName);
+ buttonnode.setAttribute('name','all-checkbox');
+ buttonnode.setAttribute('class','projectTableAllButton');
+ buttonnode.setAttribute('onClick','buildSelectAll(this)');
+ cell.appendChild(buttonnode);
+ } else {
+ /* add empty cell for all*/
+ cell = row.insertCell(-1);
+ cell.setAttribute('style', 'text-align: left');
+ cell.setAttribute('bgcolor', '#c0c0c0');
+ cell.innerHTML = "";
+ }
+}
+
function buildBuildProject() {
var distName = $("#build-distribution-select option:selected").val();
var buildProjectList = [];
postForServer(url, changeInfoList, successFunction);
}
+function changeAllProjectStatus(changeInfoList, successFunction) {
+ var url = 'admin_project/changeAllProjectStatus';
+ postForServer(url, changeInfoList, successFunction);
+}
+
// controller : admin_distribution
function queryDistributionInfo(distName, successFunction) {
var url = 'admin_distribution/queryDistributionInfo/' + distName;
require 'utils'
class BuildClientUsage
- BUILD="build-cli build -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>] [-U user-email] [-V]"
- #RESOLVE="build-cli resolve -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>] [-U user-email] [-V]"
+ BUILD="build-cli build -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>] [-U user-email]"
QUERY="build-cli query -d <server address>"
QUERY_SYSTEM="build-cli query-system -d <server address>"
QUERY_PROJECT="build-cli query-project -d <server address>"
QUERY_JOB="build-cli query-job -d <server address>"
- QUERY_LOG="build-cli query-log -d <server address> -j <job number>"
+ QUERY_LOG="build-cli query-log -d <server address> -j <job number> [--output <output file path>]"
CANCEL="build-cli cancel -j <job number> -d <server address> [-w <password>] [-U user-email]"
REGISTER="build-cli register -P <package file> -d <server address> [-t <ftp server url>] [-w <password>] [-D <distribution name>] [-U user-email]"
end
raise ArgumentError, "Usage: " + BuildClientUsage::BUILD
end
-# when "resolve" then
-# if options[:project].nil? or options[:project].empty? or
-# options[:domain].nil? or options[:domain].empty? then
-# raise ArgumentError, "Usage: " + BuildClientUsage::RESOLVE
-# end
-#
when "query" then
if options[:domain].nil? or options[:domain].empty? then
raise ArgumentError, "Usage: " + BuildClientUsage::QUERY
options[:noreverse] = "YES"
end
+ options[:rebuild] = "NO"
+ opts.on( '--rebuild', 'do not check package version' ) do
+ options[:rebuild] = "YES"
+ end
+
opts.on( '-j', '--job <job number>', 'job number' ) do|job|
options[:job] = job
end
options[:user] = user
end
+ options[:output] = nil
+ opts.on( '--output <output_path>', 'output file path' ) do|path|
+ options[:output] = path
+ end
+
options[:verbose] = "NO"
opts.on( '-V', '--verbose', 'verbose mode' ) do
options[:verbose] = "YES"
end
opts.on( '-h', '--help', 'display help' ) do
- opts.help.split("\n").each {|op| puts op if not op.include? "--noreverse"}
+ opts.help.split("\n").each {|op| puts op if not op.include? "--noreverse" and not op.include? "--rebuild"}
exit
end
exit
end
+
end
cmd = ARGV[0]
# attr_accessor :rev_fail_projects, :rev_success_jobs
# attr_accessor :pending_ancestor
attr_accessor :no_reverse
- attr_accessor :remote_id
+ attr_accessor :remote_id, :remote_status, :remote_error_msg
# initialize
def initialize (project, os, server)
#@pending_ancestor = nil # for cancel pending job
@remote_id = nil # for cancel remote_working job
@build_dep_prjs = nil # for cacnel pending job
+ @remote_status = ""
+ @remote_error_msg = ""
## for resolving build-break
#@rev_fail_projects = [] # list of [project,os]
job = nil
(@jobmgr.jobs + @jobmgr.internal_jobs + @jobmgr.reverse_build_jobs).each do |manager_job|
- if manager_job.id.eql? job_number then
+ if manager_job.id.eql? job_number.to_i then
job = manager_job
end
end
job_log_path = File.join(@path, "jobs", job_number, "log")
if File.exist? job_log_path then
- # get job status and send it
- job_status = ""
- if job.nil? then
- get_db_connection() do |db|
- job_status = db.select_one("SELECT status FROM jobs WHERE id = #{job_number}")[0]
- end
- else
- job_status = job.status
- end
- BuildCommServer.send(conn, "JOB STATUS : [[#{job_status}]]")
-
begin
File::Tail::Logfile.open(job_log_path) do |log|
- # skip log file creation information
- log.forward(1)
-
+ log.interval = 0.05
# send log file information using file-tail
log.tail { |line|
if line.strip.empty? then next end
contents = line.sub(/^[a-zA-Z], \[.*\][ \t]*/,"")
BuildCommServer.send(conn, contents)
-
+
# if read file's last line and job status ended then log file sending done
- if not job.nil? then job_status = job.status end
- if log.eof? and
- (job_status.eql? "FINISHED" or
- job_status.eql? "ERROR" or
- job_status.eql? "CANCELED") then
+ if log.eof? and (job.nil? or
+ job.status.eql? "FINISHED" or
+ job.status.eql? "ERROR" or
+ job.status.eql? "CANCELED") then
+
# Log file send done. & send job status
- BuildCommServer.send(conn, "JOB STATUS : [[#{job_status}]]")
+ job_status = ""
+ get_db_connection() do |db|
+ job_status = db.select_one("SELECT status FROM jobs WHERE id = #{job_number}")[0]
+ end
+ BuildCommServer.send(conn, "=JOB_STATUS,#{job_status}")
break
end
}
@sub_pid = 0
end
+ # processing in updated status (set stauts)
+ def status=(value)
+ @status = value
+ if not @log.nil? then
+ @log.job_status(@status, "")
+ @log.logger.flush
+ end
+ end
+
+ def status
+ return @status
+ end
+
# event check
def check_event
# CANCEL/CANCELING
@second_out = nil
end
+ def job_status(status, msg)
+ if msg.nil? then
+ BuildCommServer.send( @second_out, "=JOB_STATUS,#{status}")
+ else
+ BuildCommServer.send( @second_out, "=JOB_STATUS,#{status},#{msg}")
+ end
+ end
+
def is_connected?
if @second_out.nil? or @second_out.closed? then
# send build request
@log.info( "Sending build request to remote server...", Log::LV_USER )
- result, result_files = send_build_request(git_repos, os, is_rev_build,
- srcinfo, no_reverse, local_pkgs, dock, dist_name, user_email, @log.is_verbose)
- @log.info( "Receiving log file from remote server...", Log::LV_USER )
- if not receive_file_from_remote( "#{source_path}/../remote_log", dock ) then
- @log.warn( "File transfering failed! : remote_log", Log::LV_USER )
+ result = send_build_request(git_repos, os, is_rev_build,
+ srcinfo, no_reverse, local_pkgs, dock, dist_name, user_email)
+ if not result then
+ @log.error( "Building job request on remote server failed!", Log::LV_USER )
+ return false
end
+ result, result_files = send_monitor_request(is_rev_build)
+
if not result then
@log.error( "Building job on remote server failed!", Log::LV_USER )
return false
# send build request
protected
- def send_build_request(git_repos, os, is_rev_build, commit, no_reverse, local_pkgs, dock, dist_name, user_email, verbose)
- result_files = []
+ def send_build_request(git_repos, os, is_rev_build, commit, no_reverse, local_pkgs, dock, dist_name, user_email)
client = BuildCommClient.create( @addr, @port, @log )
if client.nil? then
@log.error( "Creating communication client failed!", Log::LV_USER)
- return false, result_files
+ return false
end
# get local package names
# send
# 0 | 1 | 2 | 3 | 4| 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
- # format: BUILD|GIT|repository|passwd|os|async|no_reverse|dist_name|user_email|verbose|internal|rev-build|commit|pkgs|dock_num
- # value : BUILD|GIT|repository| |os|NO |no_reverse|dist_name|user_email|verbose|YES |rev-build|commit|pkgs|dock_num
+ # format: BUILD|GIT|repository|passwd|os|async|no_reverse|dist_name|user_email|rebuild|internal|rev-build|commit|pkgs|dock_num
+ # value : BUILD|GIT|repository| |os|NO |no_reverse|dist_name|user_email|YES |YES |rev-build|commit|pkgs|dock_num
result = true
commit = commit.nil? ? "":commit
pkg_list = local_pkg_names.join(",")
rev = is_rev_build ? "YES":"NO"
- msg = "BUILD|GIT|#{git_repos}||#{os}|NO|#{no_reverse}|#{dist_name}|#{user_email}|#{verbose}|YES|#{rev}|#{commit}|#{pkg_list}|#{dock}"
+ msg = "BUILD|GIT|#{git_repos}||#{os}|NO|#{no_reverse}|#{dist_name}|#{user_email}|YES|YES|#{rev}|#{commit}|#{pkg_list}|#{dock}"
result = client.send( msg )
if not result then
@log.error( "Communication failed! #{client.get_error_msg()}", Log::LV_USER)
- return false, result_files
+ return false
end
- r_job_number = Regexp.new('Added new job "([^"]*)"')
- error = false
- result = client.read_lines do |l|
+ job_id = nil
+ result = client.read_lines do |line|
+ if line.strip.start_with?("=JOB_START") then
+ @job.remote_id = line.strip.split(",")[1]
+ next
+ end
# write log first
@log.output( l.strip, Log::LV_USER)
+ end
+
+ if not result then
+ @log.error( "Communication failed! #{client.get_error_msg()}", Log::LV_USER)
+ elsif @job.remote_id.nil? then
+ result = false
+ @log.error( "Can't find remote job id", Log::LV_USER)
+ end
- # set remote job id
- if not @job.nil? and @job.remote_id.nil? and l =~ r_job_number then
- @job.remote_id = $1
- end
+ # close socket
+ client.terminate
+
+ return result
+ end
+
+ # send monitor request
+ protected
+ def send_monitor_request(is_rev_build)
+ result_files = []
- # check build result
- if l.include? "Job is stopped by ERROR" or
- l.include? "Error:" then
- error = true
+ client = BuildCommClient.create( @addr, @port, @log )
+ if client.nil? then
+ @log.error( "Creating communication client failed!", Log::LV_USER)
+ return false, result_files
+ end
+
+ result = true
+ msg = "LOG|#{@job.remote_id}"
+ result = client.send( msg )
+ if not result then
+ @log.error( "Communication failed! #{client.get_error_msg()}", Log::LV_USER)
+ return false, result_files
+ end
+
+ result = client.read_lines do |l|
+ if line.strip.start_with?("=JOB_STATUS") then
+ data = line.strip.split(",")
+ @job.remote_status = data[1]
+ @job.remote_error_msg = data[2]
+ next
end
+ # write log first
+ @log.output( l.strip, Log::LV_USER)
+
# gather result files if not reverse build
if not is_rev_build and l =~ /Creating package file \.\.\. (.*)/ then
file_name = $1
result_files.push file_name
end
end
+
if not result then
@log.error( "Communication failed! #{client.get_error_msg()}", Log::LV_USER)
+ elsif not @job.remote_status.eql? "FINISHED" then
+ @log.error( "Job is #{@job.remote_status}! #{@job.remote_error_msg}", Log::LV_USER)
+ result = false
end
- if error then result=false end
# close socket
client.terminate
return result, result_files
end
-
# receive binary package of remote server
protected
def receive_file_from_remote(file_path, dock = "0")
handle_cmd_build_internal( line, req )
rescue BuildServerException => e
@log.error(e.message)
- BuildCommServer.send(req, e.err_message())
+ BuildCommServer.send(req, "=JOB_STATUS,ERROR,#{e.err_message()}")
BuildCommServer.send_end(req)
BuildCommServer.disconnect(req)
end
end
# 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
- # Case1. BUILD|GIT|project_name|passwd|os_list|async|no_reverse|dist_name|user_email|verbose
- # Case2. BUILD|GIT|git_repos | |os |async|no_reverse|dist_name|user_email|verbose|internal|rev_build|commit|pkgs|dock_num
+ # Case1. BUILD|GIT|project_name|passwd|os_list|async|no_reverse|dist_name|user_email|rebuild
+ # Case2. BUILD|GIT|git_repos | |os |async|no_reverse|dist_name|user_email|rebuild|internal|rev_build|commit|pkgs|dock_num
# parse
project_name_list = tok[2].split(",")
no_reverse = tok[6].eql? "YES"
dist_name = (not tok[7].nil? and not tok[7].empty?) ? tok[7].strip : ""
user_email = (not tok[8].nil? and not tok[8].empty?) ? tok[8].strip : ""
- verbose = tok[9].eql? "YES"
+ rebuild = tok[9].eql? "YES"
is_internal = tok[10].eql? "YES"
rev_job = tok[11].eql? "YES"
git_commit = (not tok[12].nil? and not tok[12].empty?) ? tok[12] : nil
# check reverse build
if no_reverse then new_job.set_no_reverse end
+ # set force rebuild if needed
+ if rebuild then new_job.set_force_rebuild(true) end
+
@parent_server.jobmgr.commit_job(new_job)
- # create logger and set
+ # create logger and disconnect client
+ new_job.create_logger( nil, false)
+ BuildCommServer.send(req, "=JOB_START,#{new_job.id}")
+ BuildCommServer.send(req,"Info: Added new job \"#{new_job.id}\" for #{new_job.os}!")
+ if not @parent_server.job_log_url.empty? then
+ BuildCommServer.send(req,"Info: * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log")
+ end
+
if async then
- new_job.create_logger( nil, verbose)
- BuildCommServer.send(req,"Info: Added new job \"#{new_job.id}\" for #{new_job.os}!")
- if not @parent_server.job_log_url.empty? then
- BuildCommServer.send(req,"Info: * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log")
- end
BuildCommServer.send(req,"Info: Above job(s) will be processed asynchronously!")
- BuildCommServer.send_end(req)
- BuildCommServer.disconnect(req)
- else
- logger = new_job.create_logger( req, verbose)
- logger.info( "Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
- if not @parent_server.job_log_url.empty? then
- logger.info( " * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log", Log::LV_USER)
- end
end
+ BuildCommServer.send_end(req)
+ BuildCommServer.disconnect(req)
# add to job queue
if new_job.is_rev_build_check_job() then
end
- ## "RESOLVE"
- #def handle_cmd_resolve( line, req )
- # @log.info "Received REQ: #{line}"
-
- # begin
- # handle_cmd_resolve_internal( line, req )
- # rescue BuildServerException => e
- # @log.error(e.message)
- # BuildCommServer.send(req, e.err_message())
- # BuildCommServer.send_end(req)
- # BuildCommServer.disconnect(req)
- # end
-
- # @log.info "Handled REQ: #{line}"
- #end
-
-
- #def handle_cmd_resolve_internal( line ,req)
- # tok = line.split("|").map { |x| x.strip }
- # if tok.count < 3 then
- # raise BuildServerException.new("ERR001"), line
- # end
-
- # case tok[1]
- # # RESOLVE|GIT|project_name|passwd|os|async|dist_name|user_email|verbose
- # when "GIT"
-
- # # parse
- # project_name=tok[2]
- # passwd=tok[3]
- # os=tok[4]
- # async = tok[5].eql? "YES"
- # dist_name = tok[6]
- # user_email = (not tok[7].nil? and not tok[7].empty?) ? tok[7].strip : ""
- # verbose = tok[8].eql? "YES"
- # if (dist_name.nil? or dist_name.empty?) then
- # dist_name = @parent_server.distmgr.get_default_distribution_name()
- # end
-
- # # check distribution
- # check_distribution(dist_name, req)
-
- # # check project
- # prj = check_project_exist(project_name, dist_name, req)
-
- # # check passwd
- # check_project_password(prj, passwd, req)
-
- # # check os
- # os_list = check_supported_os( [os] , req )
- # os = os_list[0]
-
- # # check user email
- # user_id = @parent_server.check_user_id_from_email( user_email )
- # if user_id == -1 then
- # raise BuildServerException.new("ERR004"), user_email
- # end
-
- # # check user accessable
- # if not check_project_user_id(project_name,dist_name,user_id) then
- # raise BuildServerException.new("ERR005"), "#{user_email} -> #{project_name}"
- # end
-
- # # create new job
- # new_job = create_new_job( project_name, os, dist_name )
- # if new_job.nil? then
- # raise BuildServerException.new("ERR006"), "Resolve job #{project_name} #{os}"
- # end
- # @log.info "Received a request for resolving this project : #{project_name}, #{os}"
-
- # new_job.user_id = user_id
-
- # # resolve
- # new_job.set_resolve_flag()
-
- # # create logger and set
- # if async then
- # new_job.create_logger( nil, verbose)
- # BuildCommServer.send(req,"Info: Added new job \"#{new_job.id}\" for #{new_job.os}!")
- # if not @parent_server.job_log_url.empty? then
- # BuildCommServer.send(req,"Info: * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log")
- # end
- # BuildCommServer.send(req,"Info: Above job(s) will be processed asynchronously!")
- # BuildCommServer.send_end(req)
- # BuildCommServer.disconnect(req)
- # else
- # logger = new_job.create_logger( req, verbose)
- # logger.info( "Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
- # if not @parent_server.job_log_url.empty? then
- # logger.info( " * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log", Log::LV_USER)
- # end
- # end
-
- # @parent_server.jobmgr.add_job( new_job )
- # else
- # raise BuildServerException.new("ERR001"), line
- # end
- #end
-
-
# "QUERY"
def handle_cmd_query( line, req )
begin
private_class_method :new
def initialize(socket, log)
+ @job_id = nil
+ @job_status = ""
+ @job_error = ""
@log = log
@socket = socket
@error_msg = ""
return @error_msg
end
+ def get_job_id
+ return @job_id
+ end
+
+ def get_job_status
+ return @job_status
+ end
+
+ def get_job_error
+ return @job_status
+ end
def set_error_msg( msg )
@error_msg = msg
end
- def print_stream
-
- begin
- l = nil
- timeout(FIRST_RESPONSE_TIMEOUT) do
- l = @socket.gets()
- end
-
- if l.nil? then
- @error_msg = "Connection closed or no more message"
- return false
- end
-
- # check protocol
- if not protocol_matched? l.strip then
- @error_msg = "Comm. Protocol version is mismatched! #{VERSION}. Upgrade your DIBS client!"
- return false
- end
-
- # get contents
- while line = @socket.gets()
- if line.strip == "=END" then break end
- if line.strip == "=CHK" then next end
- # print
- puts line.strip
- end
- rescue Timeout::Error
- @error_msg = "Connection timed out!"
- return false
-
- rescue => e
- @error_msg = e.message
- return false
- end
-
- return true
- end
-
-
# handle
def read_lines(begin_timeout = nil, data_timeout = nil)
else
line = @socket.gets()
end
- if line.nil? then break end
- if line.strip == "=END" then break end
- if line.strip == "=CHK" then next end
+
+ if line.nil? then
+ break
+ elsif line.strip == "=END" then
+ break
+ elsif line.strip == "=CHK" then
+ next
+ end
# execute
yield line.strip if block_given?
require "logger"
+class NewLogger < Logger
+ def flush
+ puts @logdev.dev.class
+ @logdev.dev.flush
+ end
+end
+
class Log
- attr_accessor :path, :cnt
+ attr_accessor :path, :cnt, :logger
# Log LEVEL
LV_NORMAL = 1
@cnt = 0
@path = path
if @path.nil? then
- @logger = Logger.new(STDOUT)
+ @logger = NewLogger.new(STDOUT)
else
- @logger = Logger.new(path, "monthly")
+ @logger = NewLogger.new(path, "monthly")
end
# if log level is bigger/equal to second out level
# , we will send the log to second-out