How to create a new Project Service

I am new to GitLab, currently evaluating it for the development process in a new team. For reasons that are beyond my control I need to integrate with TFS build. It seems, from what I have learned so far, that the only way to achieve this seamlessly would be with a new Project Service. I can’t, however, find any information on how I might go about doing that and therefore I suspect that Project Services are not so much of an arbitrary, open plug-in style model but rather a core part of the product. Is that a fair evaluation?

1 Like

I have no idea how complete this is, but I managed to get a ‘test’ project_service to show up in a project’s integrations with the following minimal patch:

diff --git a/app/models/project.rb b/app/models/project.rb
index c7dc562..0d0cba4 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -113,6 +113,7 @@ class Project < ActiveRecord::Base
   has_one :gitlab_issue_tracker_service, dependent: :destroy, inverse_of: :project
   has_one :external_wiki_service, dependent: :destroy
   has_one :kubernetes_service, dependent: :destroy, inverse_of: :project
+  has_one :test_service, dependent: :destroy, inverse_of: :project
   has_one :prometheus_service, dependent: :destroy, inverse_of: :project
   has_one :mock_ci_service, dependent: :destroy
   has_one :mock_deployment_service, dependent: :destroy
diff --git a/app/models/project_services/test_service.rb b/app/models/project_services/test_service.rb
new file mode 100644
index 0000000..b52b92b
--- /dev/null
+++ b/app/models/project_services/test_service.rb
@@ -0,0 +1,47 @@
+# Base class for deployment services
+#
+# These services integrate with a deployment solution like Kubernetes/OpenShift,
+# Mesosphere, etc, to provide additional features to environments.
+class TestService < DeploymentService
+  include Gitlab::CurrentSettings
+
+  def self.supported_events
+    %w()
+  end
+
+  def predefined_variables
+    []
+  end
+
+  def title
+    'Test'
+  end
+
+  def description
+    'A test'
+  end
+
+  def self.to_param
+    'test'
+  end
+  # Environments may have a number of terminals. Should return an array of
+  # hashes describing them, e.g.:
+  #
+  #     [{
+  #       :selectors    => {"a" => "b", "foo" => "bar"},
+  #       :url          => "wss://external.example.com/exec",
+  #       :headers      => {"Authorization" => "Token xxx"},
+  #       :subprotocols => ["foo"],
+  #       :ca_pem       => "----BEGIN CERTIFICATE...", # optional
+  #       :created_at   => Time.now.utc
+  #     }]
+  #
+  # Selectors should be a set of values that uniquely identify a particular
+  # terminal
+  def terminals(environment)
+    return [{
+       :url => "ws://localhost:2375/v1.24/containers/31a1fec34542/attach/ws?logs=1&stderr=1&stdout=1&stream=1&stdin=1"
+    }]
+    #raise NotImplementedError
+  end
+end
diff --git a/app/models/service.rb b/app/models/service.rb
index dc76bf9..4e00d56 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -226,6 +226,7 @@ class Service < ActiveRecord::Base
       hipchat
       irker
       jira
+      test
       kubernetes
       mattermost_slash_commands
       mattermost

This is almost certainly not complete, but may get someone started.