Question on Deploy phase of gitlab-ci.yaml

I have two questions:

1 - Can you prevent a git pull from the repo during the deploy phase?

2 - I have created a jar file that I want to scp from a default runner to my staging server and production server. I am falling over on attempting to do this. I was looking for any suggestions. I was wanting to use the artifact that is spelled out in the build phase to be scped over. I have set up ssh keys so no passwords. I know I will have to set up variables in my CI variables section for the private key.

Any suggestions would be great

HI there,

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

        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:

        image: alpine:latest
          - 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")
          - 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