Синтаксическая ошибка при добавлении SSH ключа в GitLab CI
Ссылка: https://gitlab.ida.liu.se/help/ci/ssh_keys/README.md
Следующий сценарий имеет проблемы. Несмотря на то, что я изменил последний символ С "на", Вопрос в том, как исправить ошибку, как показано ниже :
$ ssh-add
before_script:
# Install ssh-agent if not already installed, it is required by Docker.
# (change apt-get to yum if you use a CentOS-based image)
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
- ssh-add <(echo "$SSH_PRIVATE_KEY")
# For Docker builds disable host key checking. Be aware that by adding that
# you are suspectible to man-in-the-middle attacks.
# WARNING: Use this only with the Docker executor, if you use it with shell
# you will overwrite your user's SSH config.
- mkdir -p ~/.ssh
- '[[ -f /.dockerinit ]] && echo -e "Host *ntStrictHostKeyChecking nonn" > ~/.ssh/config`
1 ответ:
Я пробовал много раз, следующие
.gitlab-ci.yml
должны работать должным образом.image: gitlab/dind:latest variables: COMPOSE: docker-compose before_script: # Install ssh-agent if not already installed, it is required by Docker. # (change apt-get to yum if you use a CentOS-based image) - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' # Run ssh-agent (inside the build environment) - eval $(ssh-agent -s) # Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store - ssh-add <(echo "$SSH_PRIVATE_KEY") # For Docker builds disable host key checking. Be aware that by adding that # you are suspectible to man-in-the-middle attacks. # WARNING: Use this only with the Docker executor, if you use it with shell # you will overwrite your user's SSH config. - mkdir -p ~/.ssh - ssh-keyscan -H 'gitlab.com' >> ~/.ssh/known_hosts - ssh-keyscan gitlab.com | sort -u - ~/.ssh/known_hosts -o ~/.ssh/known_hosts - '[[ -f /.dockerinit ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' stages: - build - test - deploy # Add a job called 'build' -> to run your builds # TODO: Build the image in remote docker registry build-dev: stage: build script: - sh scripts/install-dev.sh - $COMPOSE build only: - dev build-master: stage: build script: - sh scripts/install.sh - $COMPOSE build only: - master
Я также открыл Вопрос здесь.