2017-09-04 2 views
0

the GitLab Docs을 따라 프로젝트 프로젝트의 CI가 다른 개인 종속성을 복제 할 수있게했습니다. 다음과 같이 별도의 쉘 스크립트 setup.shGitLab 파이프 라인 : YML에서 작동하고 추출 된 SH에서 실패 함

before_script: 
    - 'which ssh-agent || (apt-get update -y && apt-get install openssh-client -y)' 
    - eval $(ssh-agent -s) 
    - ssh-add <(echo "$SSH_PRIVATE_KEY") 
    - mkdir -p ~/.ssh 
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' 

:

which ssh-agent || (apt-get update -y && apt-get install openssh-client -y) 
eval $(ssh-agent -s) 
ssh-add <(echo "$SSH_PRIVATE_KEY") 
mkdir -p ~/.ssh 
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config 

은 떠나 :

before_script: 
- chmod 700 ./setup.sh 
- ./setup.sh 

난 후 점점 시작 :

가 작동되자, 나는 .gitlab-ci.yml에서 추출
Cloning into '/root/Repositories/DependentProject'... 
Warning: Permanently added 'gitlab.com,52.167.219.168' (ECDSA) to the list of known hosts. 
Permission denied (publickey). 
fatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 

어떻게 추출 된 스크립트에서 원래의 동작을 복제합니까?

답변

1

ssh-add를 실행하는 경우 source 또는를 사용하십시오. 스크립트가 동일한 쉘 내에서 실행되도록, 귀하의 경우에는 다음과 같습니다

before_script: 
    - chmod 700 ./setup.sh 
    - . ./setup.sh 

또는이 나머지와 같은 쉘에서 실행해야하는 이유에 더 나은 설명은

before_script: 
    - chmod 700 ./setup.sh 
    - source ./setup.sh 

관련 질문 here에 대한이 대답을 살펴보십시오.