diff --git a/before_build.sh b/before_build.sh
index c9b4d16030a467cb85e5dc75b245a17bd4aaaec9..f237b1fbb609da17e8b96b5edd8e24832459e9dd 100755
--- a/before_build.sh
+++ b/before_build.sh
@@ -12,8 +12,9 @@ for pkg in bob `cat requirements.txt | sed -e '/^\s*#.*/d;/^\s*$/d'`; do
     git -C doc/$pkg checkout master && \
     git -C doc/$pkg pull; }
     if [[ -n "${CI_COMMIT_TAG}" ]]; then
-      tag=`git -C doc/$pkg tag -l --sort="v:refname" | tail -n 1`
-      git -C doc/$pkg checkout $tag
+        git -C doc/$pkg fetch --tags
+        tag=`git -C doc/$pkg tag -l --sort="v:refname" | tail -n 1`
+        git -C doc/$pkg checkout $tag
     fi
 done