Question on Deploy phase of gitlab-ci.yaml

HI there,

  1. Yes. I believe what you want is just to set variable GIT_STRATEGY: none, e.g.

    deploy:
      variables:
        GIT_STRATEGY: none
    
  2. Perhaps would be useful to see what you’ve tried so far. This is how I normally copy my artifacts or whatever I need to target server:

    deploy:
        image: alpine:latest
        before_script:
          - apk add --no-cache openssh-client ca-certificates
          - mkdir -p ~/.ssh
          - chmod 700 ~/.ssh
          - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
          - eval $(ssh-agent -s)
          - ssh-add <(echo "$GITLAB_PRIVATE_KEY")
        script:
          - scp -r out/* user@target-host:~/target-dir
    

    GITLAB_PRIVATE_KEY is ssh private key stored as project variable. Public key you have on the target host. After you have that setup, you can use scp and ssh to do whatever you need on the target host.

Hope this helps!

1 Like