Add gearman server port configuration

This change adds the port configuration option to set a custom port
for the gearman server.

Change-Id: I1b65f93fa0403ff10e00a97afcdb4a3b512eb372
diff --git a/doc/source/admin/components.rst b/doc/source/admin/components.rst
index 2c70d47..fbb8cbc 100644
--- a/doc/source/admin/components.rst
+++ b/doc/source/admin/components.rst
@@ -149,6 +149,11 @@
 
       IP address or domain name on which to listen.
 
+   .. attr:: port
+      :default: 4730
+
+      TCP port on which to listen.
+
    .. attr:: log_config
 
       Path to log config file for internal Gearman server.
diff --git a/etc/zuul.conf-sample b/etc/zuul.conf-sample
index 6e79f9b..ba7aace 100644
--- a/etc/zuul.conf-sample
+++ b/etc/zuul.conf-sample
@@ -1,5 +1,6 @@
 [gearman]
 server=127.0.0.1
+;port=4730
 ;ssl_ca=/path/to/ca.pem
 ;ssl_cert=/path/to/client.pem
 ;ssl_key=/path/to/client.key
@@ -12,6 +13,7 @@
 ;ssl_ca=/path/to/ca.pem
 ;ssl_cert=/path/to/server.pem
 ;ssl_key=/path/to/server.key
+;port=4730
 
 [scheduler]
 tenant_config=/etc/zuul/main.yaml
diff --git a/zuul/cmd/scheduler.py b/zuul/cmd/scheduler.py
index b7b12fe..a9923c6 100755
--- a/zuul/cmd/scheduler.py
+++ b/zuul/cmd/scheduler.py
@@ -100,10 +100,12 @@
             statsd_host = os.environ.get('STATSD_HOST')
             statsd_port = int(os.environ.get('STATSD_PORT', 8125))
             host = get_default(self.config, 'gearman_server', 'listen_address')
+            port = int(get_default(self.config, 'gearman_server', 'port',
+                                   4730))
             ssl_key = get_default(self.config, 'gearman_server', 'ssl_key')
             ssl_cert = get_default(self.config, 'gearman_server', 'ssl_cert')
             ssl_ca = get_default(self.config, 'gearman_server', 'ssl_ca')
-            zuul.lib.gearserver.GearServer(4730,
+            zuul.lib.gearserver.GearServer(port,
                                            ssl_key=ssl_key,
                                            ssl_cert=ssl_cert,
                                            ssl_ca=ssl_ca,