From 48b05910d713612c851d579a6d16db4e8ac46738 Mon Sep 17 00:00:00 2001 From: Robert Rosca <robert.rosca@xfel.eu> Date: Thu, 25 Feb 2021 14:00:15 +0100 Subject: [PATCH] Use different method to modify known hosts --- .gitlab-ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d87b3b36c..3bed2dc0e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,9 +5,13 @@ stages: .setup-ssh-euxfel-gitlab: &setup-ssh-euxfel-gitlab - eval $(ssh-agent -s) - echo "$SSH_PRIVATE_KEY_GITLAB" | tr -d '\r' | ssh-add - - - mkdir -p ~/.ssh - - chmod 700 ~/.ssh - - ssh-keyscan -p 10022 git.xfel.eu > ~/.ssh/known_hosts + # Our self-hosted runners have persistent home directories, so here we store + # the known_hosts file in the temporary project dir and tell git to use a ssh + # command that uses this hosts file during operations + - export GIT_SSH_COMMAND="ssh UserKnownHostsFile=$CI_PROJECT_DIR/.ssh/known_hosts" + - mkdir -p $CI_PROJECT_DIR/.ssh + - chmod 700 $CI_PROJECT_DIR/.ssh + - ssh-keyscan -p 10022 git.xfel.eu > $CI_PROJECT_DIR/.ssh/known_hosts checks: stage: check @@ -31,6 +35,8 @@ pytest: only: [merge_requests] before_script: - *setup-ssh-euxfel-gitlab + - ls $CI_PROJECT_DIR/.ssh + - echo $GIT_SSH_COMMAND script: - python3 -m venv .venv - source .venv/bin/activate -- GitLab