if not compat_ok then
# build
if @is_remote_job then
- result = builder.build(@project.name, @project.passwd, @source_path, @os,
- use_clean, @is_rev_build_check_job, @git_commit, local_pkgs)
+ result = builder.build(@project.repository, @source_path, @os,
+ @is_rev_build_check_job, @git_commit, local_pkgs)
else
result = builder.build(@source_path, @os, use_clean, local_pkgs, false )
end
# build
if @is_remote_job then
- result = builder.build(@project.name, @project.passwd, @source_path, @os,
- true, false, @git_commit, [])
+ result = builder.build(@project.repository, @source_path, @os,
+ false, @git_commit, [])
else
result = builder.build(@source_path, @os, true, [], false )
end
# build
if @is_remote_job then
- result = builder.build(@project.name, @project.passwd, @source_path, @os, true, false, @git_commit, local_pkgs)
+ result = builder.build(@project.repository, @source_path, @os,
+ false, @git_commit, local_pkgs)
else
result = builder.build(@source_path, @os, true, local_pkgs, false )
end
# build
- def build( project_name, project_passwd, source_path, os, clean, rev_build_check_job, srcinfo, local_pkgs )
+ def build( git_repos, source_path, os, is_rev_build, srcinfo, local_pkgs )
# send local packages
for pkg_path in local_pkgs
@log.info( "Sending file... : #{pkg_path}", Log::LV_USER )
# send build request
@log.info( "Sending build request to remote server")
- result, result_files = send_build_request(project_name, project_passwd, os, clean,
- rev_build_check_job, srcinfo, local_pkgs)
+ result, result_files = send_build_request(git_repos, os,
+ is_rev_build, srcinfo, local_pkgs)
if not result then
@log.error( "Building job on remote server failed!", Log::LV_USER )
return false
# send build request
- def send_build_request( project_name, project_passwd, os, clean, rev_build_job, commit,local_pkgs)
+ def send_build_request(git_repos, os, is_rev_build, commit,local_pkgs)
result_files = []
client = BuildCommClient.create( @addr, @port, @log )
local_pkg_names = local_pkgs.map { |path| File.basename(path) }
# send
- # BUILD|GIT|project_name|os|pkgsvr_url|async|internal|commit|pkgs
+ # format: BUILD|GIT|repository|passwd|os|async|internal|rev-build|commit|pkgs
+ # value : BUILD|GIT|repository| |os|NO |YES |rev-build|commit|pkgs
result = true
commit=commit.nil? ? "":commit
pkg_list=local_pkg_names.join(",")
- rev=rev_build_job ? "YES":"NO"
- if client.send("BUILD|GIT|#{project_name}|#{project_passwd}|#{os}|NO|YES|#{rev}|#{commit}|#{pkg_list}") then
+ rev= is_rev_build ? "YES":"NO"
+ if client.send("BUILD|GIT|#{git_repos}||#{os}|NO|YES|#{rev}|#{commit}|#{pkg_list}") then
result = client.read_lines do |l|
# check build result
if l.include? "Job is stopped by ERROR" or
raise "Invalid request format is used: #{line}"
end
- case tok[1]
- # BUILD|GIT|proj|os|url|async|internal
- # "internal" means that this job requested by other server.
- when "GIT"
- # parse
- project_name_list=tok[2].split(",")
- passwd=tok[3]
- os_list=tok[4].split(",")
- async = (not tok[5].nil? and tok[5]=="YES" ? true:false)
- is_internal = (not tok[6].nil? and tok[6]=="YES" ? true:false)
-
- # for all project
- new_job_list = []
- for project_name in project_name_list
- # check project
- prj = check_project_exist(project_name, req)
- if prj.nil? then
- raise "Requested project does not exist!"
- end
-
- # check passwd
- if not check_project_password(prj, passwd, req) then
- raise "Project's password is not matched!!"
- end
+ # check type
+ if tok[1] != "GIT" then
+ @log.info "Received Wrong REQ: #{line}"
+ raise "Invalid request format is used: #{line}"
+ end
- # check os
- os_list = check_supported_os( os_list , req )
- if os_list.nil? or os_list.empty? then
- raise "Unsupported OS name is used!"
- end
+ # Case1. BUILD|GIT|project_name|passwd|os_list|async
+ # Case2. BUILD|GIT|git_repos||os|async|internal|rev_build|commit|pkgs
+
+ # parse
+ project_name_list=tok[2].split(",")
+ passwd=tok[3]
+ os_list=tok[4].split(",")
+ async = (not tok[5].nil? and tok[5]=="YES") ? true : false
+ is_internal = (not tok[6].nil? and tok[6]=="YES") ? true : false
+ rev_job = (not tok[7].nil? and tok[7].eql? "YES") ? true : false
+ git_commit = (not tok[8].nil? and not tok[8].empty?) ? tok[8] : nil
+ pkg_files = (not tok[9].nil? and not tok[9].empty?) ? tok[9].split(",") : []
+
+ # check supported os
+ os_list = check_supported_os( os_list , req )
+ if os_list.nil? or os_list.empty? then
+ raise "Unsupported OS name is used!"
+ end
- # check project type
- if prj.type == "BINARY" then
- BuildCommServer.send_begin(req)
- req.puts "Can't build about Binary type package."
- BuildCommServer.send_end(req)
- raise "Can't build about Binary type package."
- end
-
- # create new job
- for os in os_list
- new_job = create_new_job( project_name, os, req )
+ # multi build job
+ if project_name_list.count > 1 or os_list.count > 1 then
+ new_job_list = []
+ project_name_list.each { |pname|
+ check_build_project(pname,passwd,req)
+ os_list.each { |os|
+ new_job = create_new_job( pname, os, req )
if new_job.nil? then
- @log.info "Building project(#{project_name}, #{os}) is ignored."
+ @log.warn "\"#{pname}\" does not support #{os}"
next
end
new_job_list.push new_job
- @log.info "Received a request for building this project : #{project_name}, #{os}"
- end
- end
+ @log.info "Received a request for building this project : #{pname}, #{os}"
+ }
+ }
- # if multi build job,
- if new_job_list.count == 1 then
- # for all internal job, set reverse check flagd, commit-id, external_package file
- if is_internal then
- # set job type
- new_job.set_internal_job()
- # check revere_build_check_job
- rev_job = (not tok[7].nil? and tok[7].eql? "YES") ? true:false
- if rev_job then new_job.set_rev_build_check_job(nil) end
- # set commit id
- commit_id = tok[8]
- if not commit_id.nil? and not commit_id.empty? then
- new_job.set_git_commit(commit_id)
- end
- # set external pkgs
- pkg_files = tok[9].strip.split(",")
- pkg_files.each { |pkg_file|
- new_job.add_external_package( "#{@parent_server.incoming_path}/#{pkg_file}" )
- }
- end
-
- # create logger and set
- new_job = new_job_list[0]
- elsif new_job_list.count > 1 then
+ if new_job_list.count > 1 then
new_job = @parent_server.prjmgr.create_new_multi_build_job( new_job_list )
-
+ elsif new_job_list.count == 1 then
+ new_job = new_job_list[0]
else
- BuildCommServer.send_begin(req)
- req.puts "Error: There is no valid job to build!"
- BuildCommServer.send_end(req)
- raise "No valid jobs!"
+ raise "Multi-Build Job creation failed!"
end
- # create logger and set
- logger = JobLog.new( new_job, req )
- if not async then new_job.set_logger(logger) end
- logger.init
-
- # notify that job has been received
- 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
+ # transfered job
+ elsif is_internal then
+ git_repos = project_name_list[0]
+ os = os_list[0]
- # if asynchronouse, quit connection
- if async then
- logger.info( "Above job(s) will be processed asynchronously!", Log::LV_USER)
- logger.close
- end
+ new_job = create_new_internal_job(git_repos, os, git_commit, pkg_files, req)
+ if rev_job then new_job.set_rev_build_check_job(nil) end
- # add to job queue
- @parent_server.jobmgr.add_job( new_job )
+ # single job
+ elsif project_name_list.count == 1 and os_list.count == 1 then
+ pname = project_name_list[0]
+ os = os_list[0]
+
+ check_build_project(pname,passwd,req)
+ new_job = create_new_job( pname, os, req )
else
- @log.info "Received Wrong REQ: #{line}"
- raise "Invalid request format is used: #{line}"
+ BuildCommServer.send_begin(req)
+ req.puts "Error: There is no valid job to build!"
+ BuildCommServer.send_end(req)
+ raise "No valid jobs!"
+ end
+
+ # create logger and set
+ logger = JobLog.new( new_job, req )
+ if not async then new_job.set_logger(logger) end
+ logger.init
+
+ # notify that job has been received
+ 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
+
+ # if asynchronouse, quit connection
+ if async then
+ logger.info( "Above job(s) will be processed asynchronously!", Log::LV_USER)
+ logger.close
end
+
+ # add to job queue
+ @parent_server.jobmgr.add_job( new_job )
+ end
+
+
+ def check_build_project(prj_name, passwd, req)
+ # check project
+ prj = check_project_exist(prj_name, req)
+ if prj.nil? then
+ raise "Requested project does not exist!"
+ end
+
+ # check passwd
+ if not check_project_password(prj, passwd, req) then
+ raise "Project's password is not matched!!"
+ end
+
+ # check project type
+ if prj.type == "BINARY" then
+ BuildCommServer.send_begin(req)
+ req.puts "Can't build about Binary type package."
+ BuildCommServer.send_end(req)
+ raise "Can't build about Binary type package."
+ end
end
private
def create_new_job( project_name, os, req )
-
return @parent_server.prjmgr.create_new_job(project_name, os)
end
+ private
def create_new_upload_job( project_name, filename, req)
new_job = @parent_server.prjmgr.get_project(project_name).create_new_job(filename)
return new_job
end
+
+
+ private
+ def create_new_internal_job( git_repos, os, git_commit, pkg_files, req )
+ prj = @parent_server.prjmgr.get_git_project( git_repos )
+ if prj.nil? then
+ prj = @parent_server.prjmgr.create_unnamed_git_project( git_repos )
+ end
+ new_job = prj.create_new_job(os)
+ new_job.set_internal_job()
+ new_job.set_git_commit(git_commit)
+ pkg_files.each { |file|
+ new_job.add_external_package( "#{@parent_server.incoming_path}/#{file}" )
+ }
+
+ return new_job
+ end
end