build server : add uselatest option 72/14972/1
authorHyoun Jiil <jiil.hyoun@samsung.com>
Tue, 14 Jan 2014 08:54:26 +0000 (17:54 +0900)
committerHyoun Jiil <jiil.hyoun@samsung.com>
Tue, 14 Jan 2014 08:54:26 +0000 (17:54 +0900)
[Description] : support fullbuild using latest builted git commit id

Change-Id: I8448fa5b5f2df4262b4712cd66eaa34039184d54
Signed-off-by: Hyoun Jiil <jiil.hyoun@samsung.com>
build-cli
src/build_server/BuildClientOptionParser.rb
src/build_server/CommonProject.rb
src/build_server/GitBuildProject.rb
src/build_server/RemoteBuilder.rb
src/build_server/SocketJobRequestListener.rb

index 494d2097020771fd8c4f0a716b0cb01ef9d2f0cf..19265d108b0b34a56634d9b9c25eb65438ad4ffe 100755 (executable)
--- a/build-cli
+++ b/build-cli
@@ -203,6 +203,7 @@ begin
                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]
index 550e7b56eb37ad64310d697382c88ae5a7e63890..2a5c57243a76e37e3e0a15889ea98362e32571f7 100644 (file)
@@ -166,6 +166,11 @@ def option_parse
                        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"
@@ -208,7 +213,7 @@ def option_parse
                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
 
index 390f6b8d529d6f42146b4d7e7fff97ab37b19f32..fabb0c4145ebb5cb4db7705a02503ed001b3eada 100644 (file)
@@ -31,7 +31,7 @@ $LOAD_PATH.unshift File.dirname(__FILE__)
 $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" )
index 783b5c51215dffa8a6c9d393331c457f2185d66c..9ced2a72a26f671510e2452f8816f16c27a0b34e 100644 (file)
@@ -155,6 +155,4 @@ class GitBuildProject < CommonProject
         source_info = db.select_one("SELECT * FROM sources WHERE project_id =#{@prj_id} ORDER BY id DESC")
         return source_info.location
        end
-       
-        
 end
index 90a5267719c9c711e8c8e48ad41bc2ef7e93ea22..337ac6f74332e885284034cbfae5dd74db1c9de5 100644 (file)
@@ -203,6 +203,7 @@ class RemoteBuilder
                options[:pkgsvr_url] = nil
         options[:project_name] = nil
         options[:git_branch] = nil
+        options[:uselatest] = false
 
                return options
        end
@@ -307,24 +308,23 @@ class RemoteBuilder
                                # 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
index d6d0e1f9cf00d1639fc8270694e07ebd51d53baa..2d1234d8b13380338193a97d4a71b67acc8e0ddc 100644 (file)
@@ -203,8 +203,8 @@ class SocketJobRequestListener
                        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
@@ -224,6 +224,7 @@ class SocketJobRequestListener
                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
@@ -268,6 +269,9 @@ class SocketJobRequestListener
                                                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}"
@@ -297,9 +301,9 @@ class SocketJobRequestListener
                        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
@@ -315,6 +319,9 @@ class SocketJobRequestListener
                                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!"
@@ -994,6 +1001,20 @@ class SocketJobRequestListener
                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 )