diff --git a/polkadot/.gitlab-ci.yml b/polkadot/.gitlab-ci.yml
index 5e7cd41169222992899440cbf7fd0541c2ee97e0..2eb22a69b67b7ebbf770daa43df0799f6fa4f66a 100644
--- a/polkadot/.gitlab-ci.yml
+++ b/polkadot/.gitlab-ci.yml
@@ -92,6 +92,7 @@ test-linux-stable:                 &test
       test "${CI_COMMIT_REF_NAME}" = "kusama-nightly-staging" && (
         echo "kusama-nightly-staging: change Cargo.toml to build against substrate:kusama-nightly-staging"
         find . -name Cargo.toml -exec sed -i -r -e ':github.com/paritytech/substrate": { s:branch = "polkadot-(master|testing)":branch = "kusama-nightly-staging":; s:github.com/paritytech/substrate:gitlab.parity.io/parity/substrate.git:}' '{}' \;
+        sed -i -r 's:github.com/paritytech/substrate\?branch=polkadot-(master|testing):gitlab.parity.io/parity/substrate.git?branch=kusama-nightly-staging:' Cargo.lock
         time cargo test --all --release --verbose) || \
       time cargo test --all --release --verbose --locked
     - sccache -s
@@ -108,8 +109,9 @@ build-linux-release:               &build
   script:
     - |
       test "${CI_COMMIT_REF_NAME}" = "kusama-nightly-staging" && (
-        echo "kusama-nightly-staging: change Cargo.toml to build against substrate:kusama-nightly-staging";
-        find . -name Cargo.toml -exec sed -i -r -e ':github.com/paritytech/substrate": { s:branch = "polkadot-(master|testing)":branch = "kusama-nightly-staging":; s:github.com/paritytech/substrate:gitlab.parity.io/parity/substrate.git:}' '{}' \; )
+        echo "kusama-nightly-staging: change Cargo.toml to build against substrate:kusama-nightly-staging"
+        find . -name Cargo.toml -exec sed -i -r -e ':github.com/paritytech/substrate": { s:branch = "polkadot-(master|testing)":branch = "kusama-nightly-staging":; s:github.com/paritytech/substrate:gitlab.parity.io/parity/substrate.git:}' '{}' \;
+        sed -i -r 's:github.com/paritytech/substrate\?branch=polkadot-(master|testing):gitlab.parity.io/parity/substrate.git?branch=kusama-nightly-staging:' Cargo.lock )
     - time cargo build --release --verbose
     - mkdir -p ./artifacts
     - mv ./target/release/polkadot ./artifacts/.