[Title] add git clone or checkout fail error code
authorHyoun Jiil <jiil.hyoun@samsung.com>
Thu, 25 Apr 2013 02:34:52 +0000 (11:34 +0900)
committerHyoun Jiil <jiil.hyoun@samsung.com>
Thu, 25 Apr 2013 02:34:52 +0000 (11:34 +0900)
[Type] Enhancement
[Module] Toolchain /
[Priority] Minor
[Jira#]
[Redmine#] 9187
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I215b22685e4dd66ef68a2392391470812ee8b453

src/build_server/BuildServerException.rb
src/build_server/GitBuildJob.rb
test/build-server.basic1/build-cli-37.testcase [new file with mode: 0644]
test/build-server.basic1/build-cli-38.testcase [new file with mode: 0644]
test/build-server.basic1/testsuite

index 1daf4a3dabbc01fcf11e7c85d72e9db4d06cb6a6..7611d3f80675439f149a3e564607213850c4589a 100644 (file)
@@ -38,6 +38,8 @@ class BuildServerException < Exception
                "ERR108" => "Unsupported OS used in package file name!",
                "ERR109" => "Extracting package file failed!",
                "ERR110" => "Initializing sub jobs failed!",
+               "ERR111" => "Git clone failed!!",
+               "ERR112" => "Git checkout failed!!",
 
                "ERR200" => "Unmet dependency found!",
                "ERR201" => "Creating job builder failed!",
index b66d08152017e9a2fe6136afb225c0e983ec77ed..9f9c8006717a1e110c81c0bcd64aa1983c32c11b 100644 (file)
@@ -144,10 +144,6 @@ class GitBuildJob < BuildJob
 
                # download source code
                @git_commit = get_source_code()
-               if @git_commit.nil? then
-                       @status = "ERROR"
-                       return false
-               end
 
                # check pkginfo.manifest
                if not File.exist? "#{@source_path}/package/pkginfo.manifest" then
@@ -287,13 +283,11 @@ class GitBuildJob < BuildJob
                if  not File.exist? git_path then
                        # if "git pull" failed, try to "git clone"
                        if not git_cmd("clone #{@git_repos}", cache_path, @log) then
-                               @log.error( "Failed on \"git clone #{@git_repos}\"", Log::LV_USER)
-                               return nil
+                               raise BuildServerException.new("ERR111"), "git clone #{@git_repos}"
                        end
                        # git checkout
                        if not git_cmd("checkout #{@git_branch}", git_path, @log) then
-                               @log.error( "Failed on \"git checkout #{@git_branch}\"", Log::LV_USER)
-                               return nil
+                               raise BuildServerException.new("ERR112"), "git checkout #{@git_branch}"
                        end
                end
 
diff --git a/test/build-server.basic1/build-cli-37.testcase b/test/build-server.basic1/build-cli-37.testcase
new file mode 100644 (file)
index 0000000..9362416
--- /dev/null
@@ -0,0 +1,12 @@
+#PRE-EXEC
+echo "error case when wrong git repository setted"
+../../build-svr add-prj -n testserver3 -N testaErr -g `pwd`/git01/aErr -b master
+#EXEC
+../../build-cli build -N testaErr -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
+#POST-EXEC
+#EXPECT
+Info: Added new job
+Info: Initializing job...
+Error: Git clone failed!!: git clone 
+Error: Job is stopped by ERROR
+Error: Building job on remote server failed!
diff --git a/test/build-server.basic1/build-cli-38.testcase b/test/build-server.basic1/build-cli-38.testcase
new file mode 100644 (file)
index 0000000..544cc9c
--- /dev/null
@@ -0,0 +1,12 @@
+#PRE-EXEC
+echo "error case when wrong git branch setted"
+../../build-svr add-prj -n testserver3 -N testbErr -g `pwd`/git01/b -b testError
+#EXEC
+../../build-cli build -N testbErr -d 127.0.0.1:2223 -o ubuntu-32 -U admin@user -w 1234
+#POST-EXEC
+#EXPECT
+Info: Added new job
+Info: Initializing job...
+Error: Git checkout failed!!: git checkout
+Error: Job is stopped by ERROR
+Error: Building job on remote server failed!
index cfbf416d7c2a8b61011267744e0ed4c0ce8c3621..babed08705c6d32f972b96e78b5cd744744929e5 100644 (file)
@@ -34,3 +34,5 @@ build-cli-33.testcase
 build-cli-34.testcase
 build-cli-35.testcase
 build-cli-36.testcase
+build-cli-37.testcase
+build-cli-38.testcase