options[:dist] = option[:dist]
options[:user] = option[:user]
options[:rebuild] = (option[:rebuild] == "YES") ? true : false
+ options[:uselatest] = (option[:uselatest] == "YES") ? true : false
options[:async] = (option[:async] == "YES") ? true : false
options[:monitor_level] = Log::LV_USER
options[:save] = option[:save]
options[:noreverse] = "YES"
end
+ options[:uselatest] = "NO"
+ opts.on( '--uselatest', 'use latest git commit id build' ) do
+ options[:uselatest] = "YES"
+ end
+
options[:rebuild] = "NO"
opts.on( '--rebuild', 'do not check package version' ) do
options[:rebuild] = "YES"
end
opts.on( '-h', '--help', 'display help' ) do
- opts.help.split("\n").each {|op| puts op if not op.include? "--noreverse" and not op.include? "--rebuild"}
+ opts.help.split("\n").each {|op| puts op if not op.include? "--noreverse" and not op.include? "--rebuild" and not op.include? "--uselatest"}
exit
end
$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
class CommonProject
- attr_accessor :name, :type, :os_list, :dist_name, :path, :status
+ attr_accessor :name, :type, :os_list, :dist_name, :path, :status, :prj_id
# initialize
def initialize( name, type, server, os_list, dist_name="BASE", status="OPEN" )
source_info = db.select_one("SELECT * FROM sources WHERE project_id =#{@prj_id} ORDER BY id DESC")
return source_info.location
end
-
-
end
options[:pkgsvr_url] = nil
options[:project_name] = nil
options[:git_branch] = nil
+ options[:uselatest] = false
return options
end
# format: BUILD|GIT|repository|passwd|os|async|
# no_reverse|dist_name|
# user_email|rebuild|internal|rev-build|
- # commit|pkgs|dock_num|pkgsvr_url
+ # commit|pkgs|dock_num|pkgsvr_url|project_name|git_branch
msg = "BUILD|GIT|#{options[:git_repos]}||#{options[:os]}|NO|"+
"#{options[:noreverse] ? "YES" : "NO"}|#{options[:dist]}|"+
"#{options[:user]}|NO|YES|#{options[:is_rev_build] ? "YES":"NO"}|"+
"#{commit}|#{pkg_list}|#{options[:dock]}|#{options[:pkgsvr_url]}|"+
"#{options[:project_name]}|#{options[:git_branch]}"
else
- # format: BUILD|GIT|project_list|passwd|
- # os|async|
+ # format: BUILD|GIT|project_list|passwd|os|async|
# no_reverse|dist_name|
- # user_email|rebuild
- # internal|rev-build|commit|pkgs|dock_num
+ # user_email|rebuild|internal|rev-build|
+ # commit|pkgs|dock_num|pkgsvr_url|project_name|git_branch|latestCommit
msg = "BUILD|GIT|#{options[:projects]}|#{options[:passwd]}|"+
"#{options[:os]}|"+
"#{options[:async] ? "YES" : "NO"}|"+
"#{options[:noreverse] ? "YES" : "NO"}|#{options[:dist]}|"+
"#{options[:user]}|#{options[:rebuild] ? "YES" : "NO"}|"+
- "NO||||#{options[:dock].nil? ? "" : options[:dock]}"
+ "NO||||#{options[:dock].nil? ? "" : options[:dock]}||||#{options[:uselatest] ? "YES" : "NO"}"
end
if not client.send( msg ) then
raise BuildServerException.new("ERR001"), line
end
- # 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
- # Case1. BUILD|GIT|project_name|passwd|os_list|async|no_reverse|dist_name|user_email|rebuild
+ # 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18
+ # Case1. BUILD|GIT|project_name|passwd|os_list|async|no_reverse|dist_name|user_email|rebuild| | | | |dock_num| | | |latestCommit
# Case2. BUILD|GIT|git_repos | |os |async|no_reverse|dist_name|user_email|rebuild|internal|rev_build|commit|pkgs|dock_num|pkgsvr_url|project_name|git_branch
# parse
pkgsvr_url = (not tok[15].nil? and not tok[15].empty?) ? tok[15].strip : nil
project_name = (not tok[16].nil? and not tok[16].empty?) ? tok[16].strip : nil
git_branch = (not tok[17].nil? and not tok[17].empty?) ? tok[17].strip : nil
+ uselatest = tok[18].eql? "YES"
if (dist_name.nil? or dist_name.empty?) then
dist_name = @parent_server.distmgr.get_default_distribution_name()
end
next
else
new_job.user_id = user_id
+ if uselatest then
+ new_job.git_commit = get_latest_commit(pname, dist_name)
+ end
end
new_job_list.push new_job
@log.info "Received a request for building this project : #{pname}, #{os}"
if new_job.nil? then
raise BuildServerException.new("ERR006"),"Transfered-Build job"
else
- new_job.user_id = user_id
- end
- if rev_job then new_job.set_rev_build_check_job(nil) end
+ new_job.user_id = user_id
+ end
+ if rev_job then new_job.set_rev_build_check_job(nil) end
# single job
elsif project_name_list.count == 1 and os_list.count == 1 then
raise BuildServerException.new("ERR006"), "\"#{pname}\" does not support #{os} in #{dist_name}"
else
new_job.user_id = user_id
+ if uselatest then
+ new_job.git_commit = get_latest_commit(pname, dist_name)
+ end
end
else
raise BuildServerException.new("ERR006"), "Cannot find your project to build!"
return result
end
+ private
+ def get_uselatest( project_name, dist_name )
+ nPrj = @parent_server.prjmgr.get_project(project_name, dist_name)
+ if nPrj.type.eql? "GIT" then
+ result = nil
+ @parent_server.get_db_connection() do |db|
+ result = nPrj.get_latest_commit_id(db)
+ end
+ return result
+ else
+ return nil
+ end
+
+ end
private
def create_new_job( project_name, os, dist_name )