client.terminate if not client.nil?
end
+ if not result then exit(-1) 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]
+ result = JobLog.monitor(addr[0], addr[1], job_id) do |line|
+ 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
- # 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
+ next
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
- client.terminate
+ rescue BuildServerException => e
+ puts e.err_message()
+ result = false
rescue => e
puts "ERROR: #{e}"
result = false
- client.terminate
end
end
- if not result then
- exit 1
- end
+ if not result then exit(1) end
+
when "query"
result = Utils.parse_server_addr(option[:domain])
if result.nil? then
query_job_list( result[0], result[1] )
when "query-log"
- 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
-
+ result = false
addr = Utils.parse_server_addr(option[:domain])
if addr.nil? then
puts "Server address is incorrect. (#{option[:domain]})"
puts " <ip>:<port>"
exit 1
end
+ output = option[:output]
- client = BuildCommClient.create( addr[0], addr[1], nil, 0 )
- if client.nil? then
- raise RuntimeError, "The output file is already exist."
- end
+ begin
+ 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
- client.send "LOG|#{option[:job].strip}"
- 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
+ result = JobLog.monitor(addr[0], addr[1], option[:job].strip) do |line|
+ log.puts line
+ end
+ if result and not output.nil? then
+ log.puts "=LOG_END"
+ end
+ rescue BuildServerException => e
+ log.puts e.err_message()
+ result = false
+ rescue => e
+ puts "ERROR: #{e}"
+ result = false
+ ensure
+ if not output.nil? then
+ log.close if not log.nil?
end
- # print log
- log.puts line
- end
-
- if not output.nil? then
- log.puts "=LOG_END"
end
if not result then
- 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
+ FileUtils.rm output if not output.nil?
+ exit(1)
end
when "cancel"
rescue BuildServerException => e
puts e.err_message()
result = false
+ rescue => e
+ puts "ERROR: #{e}"
+ result = false
end
if not result then exit(-1) end
--- /dev/null
+#PRE-EXEC
+echo "query-log"
+#EXEC
+../../build-cli query-log -d 127.0.0.1:2223 -j 1 | grep {2} | cut -d '}' -f2
+#POST-EXEC
+#EXPECT
+Added new job
+Initializing job...
+Checking package version ...
+Invoking a thread for building Job
+New Job
+hecking build dependency ...
+Checking install dependency ...
+Started to build this job...
+JobBuilder
+ownloding client is initializing...
+Installing dependent packages...
+Downloading dependent source packages...
+Make clean...
+Make build...
+Make install...
+eneratiing pkginfo.manifest...
+Zipping...
+Creating package file ... a_0.0.1_ubuntu-32.zip
+Checking reverse build dependency ...
+Uploading ...
+Upload succeeded. Sync local pkg-server again...
+Snapshot:
+Job is completed!
+Job is FINISHED successfully!
+Updating the source info for project "testa"