diff --git a/gitlab/before_build.sh b/gitlab/before_build.sh
index cfa6e93f60e690035e92582143bb15247a4325ad..046c0afeba06373c4a17bd9c57088a5fd5fe095c 100755
--- a/gitlab/before_build.sh
+++ b/gitlab/before_build.sh
@@ -12,21 +12,7 @@ mkdir -p ${CONDA_ROOT}/pkgs
 touch ${CONDA_ROOT}/pkgs/urls
 touch ${CONDA_ROOT}/pkgs/urls.txt
 
-cat <<EOF > ${CONDARC}
-default_channels: #!final
-  - https://repo.anaconda.com/pkgs/main
-  - https://repo.anaconda.com/pkgs/free
-  - https://repo.anaconda.com/pkgs/r
-  - https://repo.anaconda.com/pkgs/pro
-add_pip_as_python_dependency: false #!final
-changeps1: false #!final
-always_yes: true #!final
-quiet: true #!final
-show_channel_urls: true #!final
-anaconda_upload: false #!final
-ssl_verify: false #!final
-channels: #!final
-EOF
+create_condarc ${CONDARC}
 
 if [[ "${STABLE}" == "true" ]]; then
   set_conda_channels ${VISIBILITY} "stable"
diff --git a/gitlab/functions.sh b/gitlab/functions.sh
index 35c213a4d5ad6b6ae764fcc1b16cfd00f779d3dd..8276a8642b275121dca87e6b6a03f69aa10d1444 100644
--- a/gitlab/functions.sh
+++ b/gitlab/functions.sh
@@ -367,6 +367,30 @@ install_miniconda() {
 }
 
 
+# Creates a sane base condarc file
+# $1: Path to where to populate the condarc file
+create_condarc() {
+  log_info "Populating the basic condarc file in ${1} ..."
+
+  cat <<EOF > ${1}
+default_channels: #!final
+  - https://repo.anaconda.com/pkgs/main
+  - https://repo.anaconda.com/pkgs/free
+  - https://repo.anaconda.com/pkgs/r
+  - https://repo.anaconda.com/pkgs/pro
+add_pip_as_python_dependency: false #!final
+changeps1: false #!final
+always_yes: true #!final
+quiet: true #!final
+show_channel_urls: true #!final
+anaconda_upload: false #!final
+ssl_verify: false #!final
+channels: #!final
+EOF
+
+}
+
+
 # sets CONDA_CHANNELS to the list of conda channels that should be considered
 # $1: visibility (maybe either "public" or "private")
 # $2: typically, the value of ${CI_COMMIT_TAG} or empty
diff --git a/gitlab/pypi.sh b/gitlab/pypi.sh
index e79ce869df71e8c0ac516e88575211723359d251..7edfa02ac5a65acf45f48f77dec2292521e0e55b 100755
--- a/gitlab/pypi.sh
+++ b/gitlab/pypi.sh
@@ -3,6 +3,8 @@
 
 source $(dirname ${0})/functions.sh
 
+create_condarc ${CONDARC}
+
 if [ "${VISIBILITY}" != "public" ]; then
   log_warn "WARNING: You cannot publish a PRIVATE to PyPI"
   log_warn "WARNING: Make this package public if you wish to do so next time"