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
+ else
+ # print log
+ puts line
end
- # print log
- puts line
end
if not result then
data = line.strip.split(",")
job_status = data[1]
job_error = data[2]
- next
- end
-
- # print log
- category, level, contents = JobLog.parse_log(line)
- if level < Log::LV_USER then next end
-
- if category == "INFO" then
- puts "Info: #{contents}"
- elsif category == "WARN" then
- puts "Warn: #{contents}"
- elsif category == "ERROR" then
- puts "Error: #{contents}"
else
- next
+ # print log
+ category, level, contents = JobLog.parse_log(line)
+ if level < Log::LV_USER then next end
+
+ if category == "INFO" then
+ puts "Info: #{contents}"
+ elsif category == "WARN" then
+ puts "Warn: #{contents}"
+ elsif category == "ERROR" then
+ puts "Error: #{contents}"
+ else
+ next
+ end
end
end
end
when "register"
+ client = nil
+ result = false
+ job_id = nil
+ job_status = ""
+ job_error = ""
+
# check file exist
if not File.exist? option[:package] then
puts "The file does not exist!.. #{option[:package]}"
begin
dock = Utils.create_uniq_name()
client.send("REGISTER|BINARY|#{File.basename(option[:package])}|#{option[:passwd]}|#{dock}|#{option[:dist]}|#{option[:user]}|#{option[:noreverse]}")
- client.read_lines do |line|
- if line.eql?("WAITFORUPLOAD") then
+ result = client.read_lines do |line|
+ if line.strip.eql?("WAITFORUPLOAD") then
# upload
thread = Thread.new do
begin
thread.join
client.send("REGISTERCONTINUE")
+ elsif line.strip.start_with?("=JOB_START") then
+ job_id = line.strip.split(",")[1]
+ elsif line.strip.start_with?("=JOB_STATUS") then
+ data = line.strip.split(",")
+ job_status = data[1]
+ job_error = data[2]
else
+ # print log
puts line
end
end
+
+ if not result then
+ puts "Error: Communication failed! #{client.get_error_msg()}"
+ elsif job_id.nil? then
+ puts job_error
+ result = false
+ end
ensure
client.terminate
end
+
+ # Query log in case sync
+ if result then
+ begin
+ client = BuildCommClient.create( bs_ip, bs_port, nil, 0 )
+ if client.nil? then
+ puts "Can't access server #{bs_ip}:#{bs_port}"
+ 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]
+ else
+ # print log
+ puts line
+ end
+ 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
+ ensure
+ client.terminate
+ end
+ end
+
+ if not result then
+ exit 1
+ end
else
raise RuntimeError, "input option incorrect : #{option[:cmd]}"
end
BuildCommServer.send_end(req)
BuildCommServer.disconnect(req)
+ 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
+
+ BuildCommServer.send(req,"Info: Above job(s) will be processed asynchronously!")
+
# add
@parent_server.jobmgr.add_job( new_job )
# create new job
@log.info "Received a request for uploading binaries : #{filename}"
- new_job = create_new_upload_job( prj.name, filename, dock, dist_name, req )
+ new_job = create_new_upload_job( prj.name, filename, dock, dist_name )
if new_job.nil? then
raise BuildServerException.new("ERR006"), "Register-job #{filename}, #{prj.name}, #{dist_name}"
end
private
- def create_new_upload_job( project_name, filename, dock, dist_name, req)
+ def create_new_upload_job( project_name, filename, dock, dist_name)
return @parent_server.prjmgr.get_project(project_name, dist_name).create_new_job(filename, dock)
end