diff --git a/docs/user/reference/environment-variables.rst b/docs/user/reference/environment-variables.rst index 68bbfb532af..3dcbd65cffe 100644 --- a/docs/user/reference/environment-variables.rst +++ b/docs/user/reference/environment-variables.rst @@ -56,6 +56,31 @@ All :doc:`build processes ` have the following environment variables au :Example: ``https://docs.readthedocs.io/ja/stable/`` :Example: ``https://example--17.org.readthedocs.build/fr/17/`` +.. envvar:: READTHEDOCS_GIT_CLONE_URL + + URL for the remote source repository, from which the documentation is cloned. + It could be HTTPS, SSH or any other URL scheme supported by Git. + This is the same URL defined in your Project's :term:`dashboard` in :menuselection:`Admin --> Settings --> Repository URL`. + + :Example: ``https://github.com/readthedocs/readthedocs.org`` + :Example: ``git@github.com:readthedocs/readthedocs.org.git`` + +.. envvar:: READTHEDOCS_GIT_IDENTIFIER + + Contains the Git identifier that was *checked out* from the remote repository URL. + Possible values are either a branch or tag name. + + :Example: ``v1.x`` + :Example: ``bugfix/docs-typo`` + :Example: ``feature/signup`` + :Example: ``update-readme`` + +.. envvar:: READTHEDOCS_GIT_COMMIT_HASH + + Git commit hash identifier checked out from the repository URL. + + :Example: ``1f94e04b7f596c309b7efab4e7630ed78e85a1f1`` + .. seealso:: :doc:`/environment-variables` diff --git a/readthedocs/doc_builder/director.py b/readthedocs/doc_builder/director.py index 4d8f3edc3dc..3a7ba1ce7bf 100644 --- a/readthedocs/doc_builder/director.py +++ b/readthedocs/doc_builder/director.py @@ -574,6 +574,12 @@ def get_rtd_env_vars(self): "READTHEDOCS_OUTPUT": os.path.join( self.data.project.checkout_path(self.data.version.slug), "_readthedocs/" ), + "READTHEDOCS_GIT_CLONE_URL": self.data.project.repo, + # TODO: we don't have access to the database from the builder. + # We need to find a way to expose HTML_URL here as well. + # "READTHEDOCS_GIT_HTML_URL": self.data.project.remote_repository.html_url, + "READTHEDOCS_GIT_IDENTIFIER": self.data.version.identifier, + "READTHEDOCS_GIT_COMMIT_HASH": self.data.build["commit"], } return env diff --git a/readthedocs/projects/tests/test_build_tasks.py b/readthedocs/projects/tests/test_build_tasks.py index 11b7212d60a..7c385a837a6 100644 --- a/readthedocs/projects/tests/test_build_tasks.py +++ b/readthedocs/projects/tests/test_build_tasks.py @@ -279,6 +279,9 @@ def test_get_env_vars(self, load_yaml_config, build_environment, config, externa "READTHEDOCS_OUTPUT": os.path.join( self.project.checkout_path(self.version.slug), "_readthedocs/" ), + "READTHEDOCS_GIT_CLONE_URL": self.project.repo, + "READTHEDOCS_GIT_IDENTIFIER": self.version.identifier, + "READTHEDOCS_GIT_COMMIT_HASH": self.build.commit, } self._trigger_update_docs_task()