2016-08-16 59 views
0

我正在嘗試遵循this指令集。試圖從travis-ci部署到gh頁面

我的travis日誌是here

0.01s$ openssl aes-256-cbc -K $encrypted_4b2755af321b_key -iv $encrypted_4b2755af321b_iv -in etc/deploy.enc -out ~/.ssh/publish-key -d 
before_install.2 
0.00s$ chmod u=rw,og= ~/.ssh/publish-key 
before_install.3 
0.00s$ echo "Host github.com" >> ~/.ssh/config 
before_install.4 
0.00s$ echo " IdentityFile ~/.ssh/publish-key" >> ~/.ssh/config 
before_install.5 
0.00s$ git --version 
git version 1.8.5.6 
before_install.6 
0.01s$ git remote set-url origin [email protected]:zaun/riot-ui.git 
$ git fetch origin -f gh-pages:gh-pages 
Warning: Permanently added the RSA host key for IP address '192.30.253.112' to the list of known hosts. 
Enter passphrase for key '/home/travis/.ssh/publish-key': 
Done: Job Cancelled 

該作業掛起/home/travis/.ssh/publish-key。密鑰沒有密碼。擊中Enter會使腳本繼續。

before_install步處理,關鍵是這樣的:

before_install: 
    - openssl aes-256-cbc -K $encrypted_4b2755af321b_key -iv $encrypted_4b2755af321b_iv -in etc/deploy.enc -out ~/.ssh/publish-key -d 
    - chmod u=rw,og= ~/.ssh/publish-key 
    - ssh-keyscan github.com >> ~/.ssh/known_hosts 
    - echo "Host github.com" >> ~/.ssh/config 
    - echo " IdentityFile ~/.ssh/publish-key" >> ~/.ssh/config 
    - git --version 
    - git remote set-url origin [email protected]:zaun/riot-ui.git 
    - git fetch origin -f gh-pages:gh-pages 

我在做什麼錯?我如何得到這個工作?

回答

0

嘗試使用ssh代理。

addons: 
    ssh_known_hosts: github.com 

before_script: 
- openssl aes-256-cbc -K $encrypted_4b2755af321b_key -iv $encrypted_4b2755af321b_iv -in etc/deploy.enc -out publish-key -d 
- chmod 600 publish-key 
- eval `ssh-agent -s` 
- ssh-add publish-key 

而且儘可能晚地執行此操作可能會更安全,以避免第三方腳本公開您的密鑰。我個人在使用git命令之前,在我的after_success腳本中執行此操作。

您可以看看this repository的完整示例。

0

如果git等待輸入,你可以嘗試餵養它一個新行:

before_install: 
    ⋮ 
    - echo | git fetch origin -f gh-pages:gh-pages