diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 928e834a607dbbc78fc52b9da1081887596e7581..8958d3b4158fd0c882a96c9aa3b5d4f5ec24afd0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -17,23 +17,24 @@ variables:
   CTA_VERSION: "${XROOTD_VERSION}"
   CMAKE_OPTIONS: ""
 
-before_script:
-  - export CTA_BUILD_ID=${CI_PIPELINE_ID}git${CI_COMMIT_SHA:0:8}
-  - echo "Exporting CTA_BUILD_ID=${CTA_BUILD_ID}"
-  - test -n "${CI_COMMIT_TAG}" && export TAG_VERSION=$(echo ${CI_COMMIT_TAG} | sed -e 's/^v//;s/-.*$//')
-  - test -n "${CI_COMMIT_TAG}" && export TAG_RELEASE=$(echo ${CI_COMMIT_TAG} | sed -e 's/^[^-]*-//')
-  - major_version=$(echo ${TAG_VERSION} | cut -d. -f1)
-  - if [[ ${major_version} == 5 ]];
-      then echo "Setting to compile with XRootD version 5";
-      XROOTD_VERSION=5;
-    fi
+.prepare-xrootd5: &prepare-xrootd5
   - if [[ ${XROOTD_VERSION} -eq 5 ]];
     then echo "Using XRootD version 5";
       sed -i 's/define xrootdVersion 1:4.12.4-1/define xrootdVersion 1:5.4.2-1/' cta.spec.in;
-      cp continuousintegration/docker/ctafrontend/cc7/cta-ci-xrootd5-enabled.repo continuousintegration/docker/ctafrontend/cc7/etc/yum.repos.d/cta-ci.repo;
-      cp -f continuousintegration/docker/ctafrontend/cc7/versionlock-xrootd5.list continuousintegration/docker/ctafrontend/cc7/etc/yum/pluginconf.d/versionlock.list;
+      repodir=$(mktemp -d)
+      awk '/cta-ci-xroot\]/{ n=NR+5 } NR==n{ $0="enabled=0" }1'
+        continuousintegration/docker/ctafrontend/cc7/etc/yum.repos.d/cta-ci.repo > ${repodir}/cta-ci.repo
+        && mv ${repodir}/cta-ci.repo continuousintegration/docker/ctafrontend/cc7/etc/yum.repos.d/cta-ci.repo;
+      awk '/cta-ci-xrootd5/{ n=NR+5 } NR==n{ $0="enabled=1" }1'
+        continuousintegration/docker/ctafrontend/cc7/etc/yum.repos.d/cta-ci.repo > ${repodir}/cta-ci.repo
+        && mv ${repodir}/cta-ci.repo continuousintegration/docker/ctafrontend/cc7/etc/yum.repos.d/cta-ci.repo;
+      . ./continuousintegration/docker/ctafrontend/cc7/opt/run/bin/versionlock_tools.sh
+        continuousintegration/docker/ctafrontend/cc7/etc/yum/pluginconf.d/versionlock.list
+        && versionlock_xrootd_4_disable && versionlock_xrootd_5_enable;
     else echo "Using XRootD version 4";
     fi
+
+.prepare-scheduler-type: &prepare-scheduler-type
   - if [[ ${SCHED_TYPE} != "objectstore" ]]; then
       echo "Using specified scheduler database type $SCHED_TYPE";
       sched_opt="-DCTA_USE_$(echo ${SCHED_TYPE} | tr '[:lower:]' '[:upper:]'):Bool=true";
@@ -42,5 +43,18 @@ before_script:
       CMAKE_OPTIONS="-DSKIP_UNIT_TESTS:STRING=1 ${sched_opt}";
     fi
 
+before_script:
+  - export CTA_BUILD_ID=${CI_PIPELINE_ID}git${CI_COMMIT_SHA:0:8}
+  - echo "Exporting CTA_BUILD_ID=${CTA_BUILD_ID}"
+  - test -n "${CI_COMMIT_TAG}" && export TAG_VERSION=$(echo ${CI_COMMIT_TAG} | sed -e 's/^v//;s/-.*$//')
+  - test -n "${CI_COMMIT_TAG}" && export TAG_RELEASE=$(echo ${CI_COMMIT_TAG} | sed -e 's/^[^-]*-//')
+  - major_version=$(echo ${TAG_VERSION} | cut -d. -f1)
+  - if [[ ${major_version} == 5 ]];
+      then echo "Setting to compile with XRootD version 5";
+      XROOTD_VERSION=5;
+    fi
+  - *prepare-xrootd5
+  - *prepare-scheduler-type
+
 include:
   - local: .gitlab/ci/*.gitlab-ci.yml
diff --git a/continuousintegration/docker/ctafrontend/cc7/cta-ci-xrootd5-enabled.repo b/continuousintegration/docker/ctafrontend/cc7/cta-ci-xrootd5-enabled.repo
deleted file mode 100644
index ebfb1f1b456289d36a9ee4830a5ba2c7baa21fbc..0000000000000000000000000000000000000000
--- a/continuousintegration/docker/ctafrontend/cc7/cta-ci-xrootd5-enabled.repo
+++ /dev/null
@@ -1,41 +0,0 @@
-[cta-ci-ceph-octopus]
-name=CTA CI repo ceph-octopus cache
-baseurl=https://cta-ci-repo.web.cern.ch/cta-ci-repo/ceph-octopus
-priority=3
-gpgcheck=0
-enabled=1
-
-[cta-ci-eos]
-name=CTA CI repo eos cache
-baseurl=https://cta-ci-repo.web.cern.ch/cta-ci-repo/eos/
-priority=4
-gpgcheck=0
-enabled=1
-
-[cta-ci-eos-5]
-name=CTA CI repo eos cache
-baseurl=https://cta-ci-repo.web.cern.ch/cta-ci-repo/eos5/
-priority=4
-gpgcheck=0
-enabled=0
-
-[cta-ci-others]
-name=CTA CI repo any additional needed RPM cache
-baseurl=https://cta-ci-repo.web.cern.ch/cta-ci-repo/others/
-priority=4
-gpgcheck=0
-enabled=1
-
-[cta-ci-xroot]
-name=CTA CI repo xroot cache
-baseurl=https://cta-ci-repo.web.cern.ch/cta-ci-repo/xroot/
-priority=4
-gpgcheck=0
-enabled=0
-
-[cta-ci-xrootd5]
-name=CTA CI repo xrootd5 cache
-baseurl=https://cta-ci-repo.web.cern.ch/cta-ci-repo/xrootd5/
-priority=4
-gpgcheck=0
-enabled=1
diff --git a/continuousintegration/docker/ctafrontend/cc7/etc/yum/pluginconf.d/versionlock.list b/continuousintegration/docker/ctafrontend/cc7/etc/yum/pluginconf.d/versionlock.list
index 6223554d1e6df7790df56452c643bf26d4a7013c..34bea4a6e972b9f85b6b71aadf3901c1f84d0398 100644
--- a/continuousintegration/docker/ctafrontend/cc7/etc/yum/pluginconf.d/versionlock.list
+++ b/continuousintegration/docker/ctafrontend/cc7/etc/yum/pluginconf.d/versionlock.list
@@ -37,6 +37,7 @@
 #### EOS-5-END ####
 0:eos-folly-2019.11.11.00-1.el7.cern.*
 0:eos-folly-deps-2019.11.11.00-1.el7.cern.*
+#### XROOTD-4-START ####
 1:python2-xrootd-4.12.6-1.el7.*
 1:python3-xrootd-4.12.6-1.el7.*
 1:xrootd-4.12.6-1.el7.*
@@ -54,6 +55,26 @@
 1:xrootd-server-devel-4.12.6-1.el7.*
 1:xrootd-server-libs-4.12.6-1.el7.*
 1:xrootd-tests-4.12.6-1.el7.*
+#### XROOTD-4-END ####
+#### XROOTD-5-START ####
+#1:python2-xrootd-5.4.2-1.el7.*
+#1:python3-xrootd-5.4.2-1.el7.*
+#1:xrootd-5.4.2-1.el7.*
+#1:xrootd-client-5.4.2-1.el7.*
+#1:xrootd-client-devel-5.4.2-1.el7.*
+#1:xrootd-client-libs-5.4.2-1.el7.*
+#1:xrootd-debuginfo-5.4.2-1.el7.*
+#1:xrootd-devel-5.4.2-1.el7.*
+#1:xrootd-doc-5.4.2-1.el7.*
+#1:xrootd-fuse-5.4.2-1.el7.*
+#1:xrootd-libs-5.4.2-1.el7.*
+#1:xrootd-private-devel-5.4.2-1.el7.*
+#1:xrootd-selinux-5.4.2-1.el7.*
+#1:xrootd-server-5.4.2-1.el7.*
+#1:xrootd-server-devel-5.4.2-1.el7.*
+#1:xrootd-server-libs-5.4.2-1.el7.*
+#1:xrootd-tests-5.4.2-1.el7.*
+#### XROOTD-5-END ####
 2:ceph-15.2.15-0.el7.x86_64
 2:ceph-base-15.2.15-0.el7.x86_64
 2:ceph-common-15.2.15-0.el7.x86_64
diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/versionlock_tools.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/versionlock_tools.sh
index 11124c61d31f7ae305afb3ee55129a822d8b589f..93b28a31c444ddb1145c8766bfc5940e8841e183 100755
--- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/versionlock_tools.sh
+++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/versionlock_tools.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+ #!/bin/bash
 
 # @project      The CERN Tape Archive (CTA)
 # @copyright    Copyright © 2022 CERN
@@ -18,6 +18,10 @@
 
 VERSIONLOCK_LIST=/etc/yum/pluginconf.d/versionlock.list
 
+if [ ! -z $1 ]
+then VERSIONLOCK_LIST=$1
+fi
+
 versionlock_eos_4_disable () {
   sed  -i '/#*\s*EOS-4-START/,/#*\s*EOS-4-END/{/#*\s*EOS-4/!{s/^[^#]/#/g}}' $VERSIONLOCK_LIST
 }
@@ -33,3 +37,19 @@ versionlock_eos_5_disable () {
 versionlock_eos_5_enable () {
   sed  -i '/#*\s*EOS-5-START/,/#*\s*EOS-5-END/{/#*\s*EOS-5/!{s/^#//g}}' $VERSIONLOCK_LIST
 }
+
+versionlock_xrootd_4_disable () {
+  sed  -i '/#*\s*XROOTD-4-START/,/#*\s*XROOTD-4-END/{/#*\s*XROOTD-4/!{s/^[^#]/#/g}}' $VERSIONLOCK_LIST
+}
+
+versionlock_xrootd_4_enable () {
+  sed  -i '/#*\s*XROOTD-4-START/,/#*\s*XROOTD-4-END/{/#*\s*XROOTD-4/!{s/^#//g}}' $VERSIONLOCK_LIST
+}
+
+versionlock_xrootd_5_disable () {
+  sed  -i '/#*\s*XROOTD-5-START/,/#*\s*XROOTD-5-END/{/#*\s*XROOTD-5/!{s/^[^#]/#/g}}' $VERSIONLOCK_LIST
+}
+
+versionlock_xrootd_5_enable () {
+  sed  -i '/#*\s*XROOTD-5-START/,/#*\s*XROOTD-5-END/{/#*\s*XROOTD-5/!{s/^#//g}}' $VERSIONLOCK_LIST
+}
diff --git a/continuousintegration/docker/ctafrontend/cc7/versionlock-xrootd5.list b/continuousintegration/docker/ctafrontend/cc7/versionlock-xrootd5.list
deleted file mode 100644
index b782234132de5fd3b55e6fea0bf5d2346275b515..0000000000000000000000000000000000000000
--- a/continuousintegration/docker/ctafrontend/cc7/versionlock-xrootd5.list
+++ /dev/null
@@ -1,96 +0,0 @@
-#### EOS-4-START ####
-0:eos-archive-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-cleanup-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-client-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-fuse-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-fuse-core-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-fuse-sysv-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-fusex-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-fusex-core-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-fusex-selinux-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-ns-inspect-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-server-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-srm-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-test-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-testkeytab-4.8.87-1.el7.cern.x86_64.rpm
-0:eos-xrootd-4.12.8-1.el7.cern.*
-0:eos-xrootd-debuginfo-4.12.8-1.el7.cern.*
-#### EOS-4-END ####
-#### EOS-5-START ####
-#0:eos-archive-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-cleanup-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-client-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-fuse-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-fuse-core-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-fuse-sysv-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-fusex-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-fusex-core-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-fusex-selinux-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-ns-inspect-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-server-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-srm-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-test-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-testkeytab-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-quarkdb-5.0.25-1.el7.cern.x86_64.rpm
-#0:eos-xrootd-5.4.4-1.el7.cern.*
-#0:eos-xrootd-debuginfo-5.4.4-1.el7.cern.*
-#### EOS-5-END ####
-0:eos-folly-2019.11.11.00-1.el7.cern.*
-0:eos-folly-deps-2019.11.11.00-1.el7.cern.*
-1:xrootd-5.4.2-1.el7.*
-1:xrootd-client-5.4.2-1.el7.*
-1:xrootd-client-devel-5.4.2-1.el7.*
-1:xrootd-client-libs-5.4.2-1.el7.*
-1:xrootd-debuginfo-5.4.2-1.el7.*
-1:xrootd-devel-5.4.2-1.el7.*
-1:xrootd-doc-5.4.2-1.el7.*
-1:xrootd-fuse-5.4.2-1.el7.*
-1:xrootd-libs-5.4.2-1.el7.*
-1:xrootd-private-devel-5.4.2-1.el7.*
-1:xrootd-selinux-5.4.2-1.el7.*
-1:xrootd-server-5.4.2-1.el7.*
-1:xrootd-server-devel-5.4.2-1.el7.*
-1:xrootd-server-libs-5.4.2-1.el7.*
-1:xrootd-tests-5.4.2-1.el7.*
-2:ceph-15.2.15-0.el7.x86_64
-2:ceph-base-15.2.15-0.el7.x86_64
-2:ceph-common-15.2.15-0.el7.x86_64
-2:ceph-debuginfo-15.2.15-0.el7.x86_64
-2:cephfs-java-15.2.15-0.el7.x86_64
-2:ceph-fuse-15.2.15-0.el7.x86_64
-2:ceph-mds-15.2.15-0.el7.x86_64
-2:ceph-mgr-15.2.15-0.el7.x86_64
-2:ceph-mon-15.2.15-0.el7.x86_64
-2:ceph-osd-15.2.15-0.el7.x86_64
-2:ceph-radosgw-15.2.15-0.el7.x86_64
-2:ceph-resource-agents-15.2.15-0.el7.x86_64
-2:ceph-selinux-15.2.15-0.el7.x86_64
-2:ceph-test-15.2.15-0.el7.x86_64
-2:libcephfs2-15.2.15-0.el7.x86_64
-2:libcephfs-devel-15.2.15-0.el7.x86_64
-2:libcephfs_jni1-15.2.15-0.el7.x86_64
-2:libcephfs_jni-devel-15.2.15-0.el7.x86_64
-2:librados2-15.2.15-0.el7.x86_64
-2:librados-devel-15.2.15-0.el7.x86_64
-2:libradospp-devel-15.2.15-0.el7.x86_64
-2:libradosstriper1-15.2.15-0.el7.x86_64
-2:libradosstriper-devel-15.2.15-0.el7.x86_64
-2:librbd1-15.2.15-0.el7.x86_64
-2:librbd-devel-15.2.15-0.el7.x86_64
-2:librgw2-15.2.15-0.el7.x86_64
-2:librgw-devel-15.2.15-0.el7.x86_64
-2:python3-ceph-argparse-15.2.15-0.el7.x86_64
-2:python3-cephfs-15.2.15-0.el7.x86_64
-2:python3-rados-15.2.15-0.el7.x86_64
-2:python3-rbd-15.2.15-0.el7.x86_64
-2:python3-rgw-15.2.15-0.el7.x86_64
-2:python-ceph-argparse-15.2.15-0.el7.x86_64
-2:python-ceph-compat-15.2.15-0.el7.x86_64
-2:python-cephfs-15.2.15-0.el7.x86_64
-2:python-rados-15.2.15-0.el7.x86_64
-2:python-rbd-15.2.15-0.el7.x86_64
-2:python-rgw-15.2.15-0.el7.x86_64
-2:rados-objclass-devel-15.2.15-0.el7.x86_64
-2:rbd-fuse-15.2.15-0.el7.x86_64
-2:rbd-mirror-15.2.15-0.el7.x86_64
-2:rbd-nbd-15.2.15-0.el7.x86_64