class BuildJob < CommonJob
attr_accessor :pkginfo, :source_path
- attr_accessor :pkgsvr_client, :thread
+ attr_accessor :pkgsvr_client
# attr_accessor :rev_fail_projects, :rev_success_jobs
# attr_accessor :pending_ancestor
attr_accessor :no_reverse
# this item will be initialized on pre-verify
@pkginfo = nil
@pkgsvr_client = nil
- @thread = nil
@log = nil
@parent = nil # for job hierachy
kill_sub_process()
# cancel all its sub jobs
- @sub_jobs.select{|x| x.event == "NONE"}.each do |sub|
+ @sub_jobs.select{|x| x.event == "NONE" and x.status != "FINISHED" and x.status != "ERROR" and x.status != "CANCELED" }.each do |sub|
sub.event = "CANCEL"
end
end
end
- # cancel log print
- if not @log.nil? then
- @log.info( "JOB is canceled by cancel operation !!", Log::LV_USER)
- end
-
- case @status
- when "REMOTE_WORKING" then
+ if @status == "REMOTE_WORKING" then
client = BuildCommClient.create( @remote_server.ip, @remote_server.port, @log )
if not client.nil? then
client.send "CANCEL|#{@remote_id}|#{self.get_project.passwd}|admin@user"
end
client.terminate
end
- #when "PENDING" then
- # if @pending_ancestor.nil? then
- # #resolve pending job
- # pending_descendants = @server.jobmgr.jobs.select do |j|
- # (not j.pending_ancestor.nil?) and "#{j.pending_ancestor.id}" == "#{@id}"
- # end
- # pending_descendants.each do |pd|
- # pd.cancel_state = "INIT"
- # end
- # else
- # # remove myself from success job if exist
- # # and add myself into rev_fail_project list if not exist
- # @pending_ancestor.remove_rev_success_job(self)
- # @pending_ancestor.add_rev_fail_project( @project, @os )
-
- # # remove the project that depends on me if exist
- # # and add it into rev_fail_project list if not exist
- # p_sub_jobs = @server.jobmgr.jobs.select do |j|
- # ( not j.pending_ancestor.nil? and
- # "#{j.pending_ancestor.id}" == "#{@pending_ancestor.id}" and
- # j.is_build_dependent_project(@project, @os) )
- # end
- # p_sub_jobs.each do |d|
- # @pending_ancestor.remove_rev_success_job(d)
- # @pending_ancestor.add_rev_fail_project( d.get_project, d.os )
-
- # if not d.thread.nil? then d.thread.terminate end
- # d.status = "WAITING"
- # end
- # end
- when "WORKING", "WAITING" , "INITIALIZING" , "JUST_CREATED" then
- #just log
- else # ERROR | FINISHED | RESOLVED
- #do noting
+ end
+
+ # wait for job thread to finish
+ @thread.join if not @thread.nil?
+
+ # cancel log print
+ if not @log.nil? then
+ @log.info( "JOB is canceled by cancel operation !!", Log::LV_USER)
end
end
class CommonJob
attr_accessor :id, :server, :log, :status, :priority
- attr_accessor :os, :type, :pre_jobs, :user_id, :event, :sub_jobs
+ attr_accessor :os, :type, :pre_jobs, :user_id, :event, :sub_jobs, :thread
USER_JOB_PRIORITY = 100
AUTO_JOB_PRIORITY = 0
@start_time = Time.now
@end_time = nil
+ @thread = nil
@sub_pid = 0
end
#cancel
public
def cancel()
+ kill_sub_process
+
+ @sub_jobs.select{|x| x.event == "NONE" and x.status != "FINISHED" and x.status != "ERROR" and x.status != "CANCELED" }.each do |sub|
+ sub.event = "CANCEL"
+ end
+ # wait for job thread to finish
+ @thread.join if not @thread.nil?
+
if not @log.nil? then
@log.info( "JOB is canceled by cancel operation !!", Log::LV_USER)
end
@server.log.info "Creating thread for canceling the job \"#{job.id}\""
Thread.new do
begin
- job.kill_sub_process
-
- job.sub_jobs.select{|x| x.event == "NONE" and x.status != "FINISHED" and x.status != "ERROR" and x.status != "CANCELED" }.each do |sub|
- sub.event = "CANCEL"
- end
- job.thread.join if not job.thread.nil?
-
- # job cacncel
+ # job cancel
job.cancel
# cancel finished
class MultiBuildJob < CommonJob
attr_accessor :source_path
- attr_accessor :pkgsvr_client, :thread
+ attr_accessor :pkgsvr_client
# initialize
def initialize (server)
class RegisterPackageJob < CommonJob
attr_accessor :source_path
- attr_accessor :pkgsvr_client, :thread, :pkg_type
+ attr_accessor :pkgsvr_client, :pkg_type
attr_accessor :pkg_name, :pkginfo
attr_accessor :no_reverse
end
- #cancel
- def cancel()
- if not @log.nil? then
- @log.info( "JOB is canceled by cancel operation !!", Log::LV_USER)
- end
- end
-
-
# check building is possible
def can_be_built_on?(host_os)
return true
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] [-V]
-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>]
-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>
+ 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
--V, --verbose verbose mode
--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
+ -h, --help display help
+ -v, --version display version