Add ZUUL_CACHE_DIR to zuul-cloner

Set the default cache directory using the ZUUL_CACHE_DIR variable so
users don't have to pass it explicitly every time.

This change does not set up --cache-dir like the other environment
variable-based options with a --zuul prefix because I did not want to
break backwards compatibility by changing the option name.

Change-Id: I1dab9dadda3a9ccf028561b09fdd78929d1dbfe7
diff --git a/doc/source/cloner.rst b/doc/source/cloner.rst
index 2ddf0b5..ccb04b6 100644
--- a/doc/source/cloner.rst
+++ b/doc/source/cloner.rst
@@ -87,3 +87,7 @@
 The URL of origin remote of the resulting clone will be reset to use
 the ``git_base_url`` and then the remote will be updated so that the
 repository has all the information in the upstream repository.
+
+The default for ``--cache-dir`` is taken from the environment variable
+``ZUUL_CACHE_DIR``. A value provided explicitly on the command line
+overrides the environment variable setting.
diff --git a/zuul/cmd/cloner.py b/zuul/cmd/cloner.py
index e4a0e7b..30401d6 100755
--- a/zuul/cmd/cloner.py
+++ b/zuul/cmd/cloner.py
@@ -51,8 +51,11 @@
                             version=self._get_version(),
                             help='show zuul version')
         parser.add_argument('--cache-dir', dest='cache_dir',
+                            default=os.environ.get('ZUUL_CACHE_DIR'),
                             help=('a directory that holds cached copies of '
-                                  'repos from which to make an initial clone.'
+                                  'repos from which to make an initial clone. '
+                                  'Can also be set via ZUUL_CACHE_DIR '
+                                  'environment variable.'
                                   ))
         parser.add_argument('git_base_url',
                             help='reference repo to clone from')