making a pipeline able to git clone a private repo on gitlab

#378
Raw
Created
Sept. 4, 2021, 11:38 p.m.
Expires
Never
Size
878 bytes
Hits
339
Syntax
YAML
Private
No
build-job:       # This job runs in the build stage, which runs first.
  stage: build
  before_script:
    # install ssh-agent
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    # run ssh-agent
    - eval $(ssh-agent -s)
    # add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
    # disable host key checking (NOTE: makes you susceptible to man-in-the-middle attacks)
    # WARNING: use only in docker container, if you use it with shell you will overwrite your user's ssh config
    - mkdir -p ~/.ssh
    - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
  script:
    - git clone git@gitlab.com:socraticdev/tf-modules-vendingmachine.git
    - echo "Compiling the code..."
    - echo "Compile complete."