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[:rebuild]}"
- 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
+ rescue => e
+ puts "ERROR: #{e}"
client.terminate
- else
- puts "Connection to server failed!"
+ 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]
+ 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
+ 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 => e
+ puts "ERROR: #{e}"
+ result = false
+ client.terminate
+ end
+ end
+
+ if not result then
exit 1
end
-
- # when "resolve"
- # 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>"
- # exit 1
- # end
- # client = BuildCommClient.create( result[0], result[1], nil, 0 )
- # if not client.nil? then
- # client.send "RESOLVE|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:dist]}|#{option[:user]}|#{option[:verbose]}"
- # if not client.print_stream then
- # puts "ERROR: #{client.get_error_msg()}"
- # end
- # client.terminate
- # end
when "query"
result = Utils.parse_server_addr(option[:domain])
if result.nil? 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.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)
++ 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
# check distribution
check_distribution(dist_name, req)
+ # check project
+ prj = check_project_for_package_file_name(filename, dist_name, req)
+
+ # check project status
+ if prj.status != "OPEN" then
+ raise BuildServerException.new("ERR017"), "#{prj.name} on #{dist_name}. project is [[#{prj.status}]]"
+ end
+
new_job = @parent_server.jobmgr.create_new_register_job( file_path, dist_name )
- new_job.create_logger( req )
+ new_job.create_logger()
+
+ BuildCommServer.send_end(req)
+ BuildCommServer.disconnect(req)
# add
@parent_server.jobmgr.add_job( new_job )
Usage: build-cli <SUBCOMMAND> [OPTS] or build-cli (-h|-v)
Subcommands:
- build Build and create package.
- query Query information about build-server.
- query-system Query system information about build-server.
- query-project Query project information about build-server.
- query-job Query job information about build-server.
- query-log Query log contents about job in build-server.
- cancel Cancel a building project.
- register Register the package to the build-server.
+ build Build and create package.
+ query Query information about build-server.
+ query-system Query system information about build-server.
+ query-project Query project information about build-server.
+ query-job Query job information about build-server.
+ query-log Query log contents about job in build-server.
+ cancel Cancel a building project.
+ register Register the package to the build-server.
Subcommand usage:
- build-cli build -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>] [-U user-email]
- build-cli query -d <server address>
- build-cli query-system -d <server address>
- build-cli query-project -d <server address>
- build-cli query-job -d <server address>
- build-cli query-log -d <server address> -j <job number>
- build-cli cancel -j <job number> -d <server address> [-w <password>] [-U user-email]
- build-cli register -P <package file> -d <server address> [-t <ftp server url>] [-w <password>] [-D <distribution name>] [-U user-email]
+build-cli build -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>] [-U user-email]
+build-cli query -d <server address>
+build-cli query-system -d <server address>
+build-cli query-project -d <server address>
+build-cli query-job -d <server address>
+build-cli query-log -d <server address> -j <job number> [--output <output file path>]
+build-cli cancel -j <job number> -d <server address> [-w <password>] [-U user-email]
+build-cli register -P <package file> -d <server address> [-t <ftp server url>] [-w <password>] [-D <distribution name>] [-U user-email]
Options:
- -N, --project <project name> project name
- -d, --address <server address> build server address: 127.0.0.1:2224
- -o, --os <operating system> target operating system: ubuntu-32/ubuntu-64/windows-32/windows-64/macos-64
- --async asynchronous job
- -j, --job <job number> job number
- -w, --passwd <password> password for managing project
- -P, --pkg <package file> package file path
- -D, --dist <distribution name> distribution name
- -t, --ftp <ftp server url> ftp server url: ftp://dibsftp:dibsftp@127.0.0.1
- -U, --user <user email> user email infomation
- -h, --help display help
- -v, --version display version
+-N, --project <project name> project name
+-d, --address <server address> build server address: 127.0.0.1:2224
+-o, --os <operating system> target operating system: ubuntu-32/ubuntu-64/windows-32/windows-64/macos-64
+--async asynchronous job
+-j, --job <job number> job number
+-w, --passwd <password> password for managing project
+-P, --pkg <package file> package file path
+-D, --dist <distribution name> distribution name
+-t, --ftp <ftp server url> ftp server url: ftp://dibsftp:dibsftp@127.0.0.1
+-U, --user <user email> user email infomation
+--output <output_path> output file path
+-V, --verbose verbose mode
+-h, --help display help
+-v, --version display version