diff --git a/lib/ci/api/entities.rb b/lib/ci/api/entities.rb
index 6b82b2b4f13d88db7f248c5d0eddd02e0e2c56db..31f66dd5a58c01c6688930e684922c9492b63526 100644
--- a/lib/ci/api/entities.rb
+++ b/lib/ci/api/entities.rb
@@ -52,7 +52,7 @@ module Ci
           # when old API will be removed (planned for August 2017).
           model.options.dup.tap do |options|
             options[:image] = options[:image][:name] if options[:image].is_a?(Hash)
-            options[:services].map! do |service|
+            options[:services]&.map! do |service|
               if service.is_a?(Hash)
                 service[:name]
               else
diff --git a/spec/requests/ci/api/builds_spec.rb b/spec/requests/ci/api/builds_spec.rb
index c969d08d0ddd529e43c6470131f1594e8f56db00..49e815ee16c9d7d0376ce5e59546d572e36c48af 100644
--- a/spec/requests/ci/api/builds_spec.rb
+++ b/spec/requests/ci/api/builds_spec.rb
@@ -69,6 +69,72 @@ describe Ci::API::Builds do
         end
       end
 
+      context 'when an old image syntax is used' do
+        before do
+          build.update!(options: { image: 'codeclimate' })
+        end
+
+        it 'starts a build' do
+          register_builds info: { platform: :darwin }
+
+          expect(response).to have_http_status(201)
+          expect(json_response["options"]).to eq({ "image" => "codeclimate" })
+        end
+      end
+
+      context 'when a new image syntax is used' do
+        before do
+          build.update!(options: { image: { name: 'codeclimate' } })
+        end
+
+        it 'starts a build' do
+          register_builds info: { platform: :darwin }
+
+          expect(response).to have_http_status(201)
+          expect(json_response["options"]).to eq({ "image" => "codeclimate" })
+        end
+      end
+
+      context 'when an old service syntax is used' do
+        before do
+          build.update!(options: { services: ['mysql'] })
+        end
+
+        it 'starts a build' do
+          register_builds info: { platform: :darwin }
+
+          expect(response).to have_http_status(201)
+          expect(json_response["options"]).to eq({ "services" => ["mysql"] })
+        end
+      end
+
+      context 'when a new service syntax is used' do
+        before do
+          build.update!(options: { services: [name: 'mysql'] })
+        end
+
+        it 'starts a build' do
+          register_builds info: { platform: :darwin }
+
+          expect(response).to have_http_status(201)
+          expect(json_response["options"]).to eq({ "services" => ["mysql"] })
+        end
+      end
+
+      context 'when no image or service is defined' do
+        before do
+          build.update!(options: {})
+        end
+
+        it 'starts a build' do
+          register_builds info: { platform: :darwin }
+
+          expect(response).to have_http_status(201)
+      
+          expect(json_response["options"]).to be_empty
+        end
+      end
+
       context 'when there is a pending build' do
         it 'starts a build' do
           register_builds info: { platform: :darwin }