summaryrefslogtreecommitdiff
path: root/tests/platform-ci/ci-build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/platform-ci/ci-build.sh')
-rwxr-xr-xtests/platform-ci/ci-build.sh35
1 files changed, 25 insertions, 10 deletions
diff --git a/tests/platform-ci/ci-build.sh b/tests/platform-ci/ci-build.sh
index 06af59ca..843642a4 100755
--- a/tests/platform-ci/ci-build.sh
+++ b/tests/platform-ci/ci-build.sh
@@ -12,9 +12,9 @@
# * AWS credentials as environment variables:
# * `AWS_ACCESS_KEY`
# * `AWS_SECRET_KEY`
-# * ssh private key used to login to remove vm
-# * `SSH_PRIVATE_KEY`
-#
+# * ssh private keys used to clone providers:
+# * `bitmask_PROVIDER_SSH_PRIVATE_KEY`
+# * `ibex_PROVIDER_SSH_PRIVATE_KEY`
# exit if any commands returns non-zero status
set -e
@@ -70,7 +70,26 @@ test() {
LEAP_CMD test "$TAG"
}
+ssh_setup() {
+ # set the provider name from the first argument passed to the function
+ provider_name=$1
+ # set CI_SSH_SECRET_PRIVATE_KEY to the variable name keyed off of the provider_name
+ CI_SSH_SECRET_PRIVATE_KEY=${provider_name}_PROVIDER_SSH_PRIVATE_KEY
+ # Set the SSH_PRIVATE_KEY to the value provided in the CI runner secret variable setting in gitlab
+ SSH_PRIVATE_KEY=${!CI_SSH_SECRET_PRIVATE_KEY}
+ echo "Working with provider: $provider_name"
+ [ -z "$SSH_PRIVATE_KEY" ] && fail "${provider_name}_PROVIDER_SSH_PRIVATE_KEY is not set - please provide it as env variable."
+ # Configure ssh keypair
+ [ -d ~/.ssh ] || /bin/mkdir ~/.ssh
+ /bin/echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
+ /bin/chmod 600 ~/.ssh/id_rsa
+ /bin/cp "${ROOTDIR}/provider/users/gitlab-runner-${provider_name}/gitlab-runner-${provider_name}_ssh.pub" ~/.ssh/id_rsa.pub
+}
+
build_from_scratch() {
+ # setup ssh keys
+ ssh_setup platform
+
# allow passing into the function the services, use a default set if empty
SERVICES=$1
if [ -z "$SERVICES" ]
@@ -100,7 +119,6 @@ build_from_scratch() {
[ -z "$AWS_ACCESS_KEY" ] && fail "\$AWS_ACCESS_KEY is not set - please provide it as env variable."
[ -z "$AWS_SECRET_KEY" ] && fail "\$AWS_SECRET_KEY is not set - please provide it as env variable."
- [ -z "$SSH_PRIVATE_KEY" ] && fail "\$SSH_PRIVATE_KEY is not set - please provide it as env variable."
/usr/bin/jq ".platform_ci.auth |= .+ {\"aws_access_key_id\":\"$AWS_ACCESS_KEY\", \"aws_secret_access_key\":\"$AWS_SECRET_KEY\"}" < cloud.json.template > cloud.json
# Enable xtrace again only if it was set at beginning of script
@@ -140,6 +158,9 @@ run() {
provider_URI=$2
platform_branch=$3
+ # setup ssh keys
+ ssh_setup "$provider_name"
+
# Setup the provider repository
echo "Setting up the provider repository: $provider_name by cloning $provider_URI"
git clone -q --depth 1 "$provider_URI"
@@ -232,12 +253,6 @@ cleanup() {
# Ensure we don't output secret stuff to console even when running in verbose mode with -x
set +x
-# Configure ssh keypair
-[ -d ~/.ssh ] || /bin/mkdir ~/.ssh
-/bin/echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
-/bin/chmod 600 ~/.ssh/id_rsa
-/bin/cp "${ROOTDIR}/provider/users/gitlab-runner/gitlab-runner_ssh.pub" ~/.ssh/id_rsa.pub
-
# Enable xtrace again only if it was set at beginning of script
[[ $xtrace == true ]] && set -x