【发布时间】:2014-04-18 23:17:41
【问题描述】:
我正在尝试通过 jenkins 作业中的 capistrano 3 部署到服务器。
“cap environment deploy”在我的 mac 和我的凭据下完美运行,但是在 jenkins 下,使用部署凭据,我遇到了问题。
超级奇怪的是,前几个 git 命令成功了,但是当 capistrano 到达“git remote update”时,服务器挂了一个“未授权”错误。我已经通过 ssh'ing 到服务器并从 /var/www/repo 运行 'git remote update' 验证了这一点。
我已经设置了密钥转发——下面是我的 Jenkins 工作:
eval $(ssh-agent)
ssh-add ~/.ssh/keyname.pem
cap staging deploy
我不知道 capistrano 内部发生了什么会导致第一个 git 命令成功('git ls-remote'),但“git remote update”失败。是的,密钥已作为部署密钥添加到 github 上,用于 repo,并且在 deploy.rb 和 ~/.ssh/config 中启用了密钥转发。
以下是来自“cap staging deploy”的示例失败日志,在 Jenkins 盒子上以 Jenkins 用户身份运行:
INFO [d3e19149] Running /usr/bin/env mkdir -p /tmp/project/ on server.xxxxxyyyy.com
DEBUG [d3e19149] Command: /usr/bin/env mkdir -p /tmp/project/
INFO [d3e19149] Finished in 0.943 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/project/git-ssh.sh 0.0%
INFO Uploading /tmp/project/git-ssh.sh 100.0%
INFO [43533553] Running /usr/bin/env chmod +x /tmp/project/git-ssh.sh on server.xxxxxyyyy.com
DEBUG [43533553] Command: /usr/bin/env chmod +x /tmp/project/git-ssh.sh
INFO [43533553] Finished in 0.052 seconds with exit status 0 (successful).
DEBUG [40e092d5] Running /usr/bin/env git ls-remote git@github.com:Organization/project.git on server.xxxxxyyyy.com
DEBUG [40e092d5] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/project/git-ssh.sh /usr/bin/env git ls-remote git@github.com:Organization/project.git )
DEBUG [40e092d5] 69a8427388e2958e9b2c67e6048a46cb3a2544a5 HEAD
DEBUG [40e092d5] 69a8427388e2958e9b2c67e6048a46cb3a2544a5 refs/heads/master
DEBUG [40e092d5] Finished in 1.635 seconds with exit status 0 (successful).
INFO [3d9e0765] Running /usr/bin/env mkdir -pv /var/www/shared /var/www/releases on server.xxxxxyyyy.com
DEBUG [3d9e0765] Command: /usr/bin/env mkdir -pv /var/www/shared /var/www/releases
INFO [3d9e0765] Finished in 0.046 seconds with exit status 0 (successful).
INFO [3ef2c63f] Running /usr/bin/env mkdir -pv /var/www/shared/log /var/www/shared/tmp/pids /var/www/shared/tmp/cache /var/www/shared/tmp/sockets /var/www/shared/vendor/bundle /var/www/shared/public/system on server.xxxxxyyyy.com
DEBUG [3ef2c63f] Command: /usr/bin/env mkdir -pv /var/www/shared/log /var/www/shared/tmp/pids /var/www/shared/tmp/cache /var/www/shared/tmp/sockets /var/www/shared/vendor/bundle /var/www/shared/public/system
INFO [3ef2c63f] Finished in 0.043 seconds with exit status 0 (successful).
INFO [a0820d89] Running /usr/bin/env mkdir -pv /var/www/shared/config on server.xxxxxyyyy.com
DEBUG [a0820d89] Command: /usr/bin/env mkdir -pv /var/www/shared/config
INFO [a0820d89] Finished in 0.050 seconds with exit status 0 (successful).
DEBUG [19575759] Running /usr/bin/env [ -f /var/www/shared/config/database.yml ] on server.xxxxxyyyy.com
DEBUG [19575759] Command: [ -f /var/www/shared/config/database.yml ]
DEBUG [19575759] Finished in 0.063 seconds with exit status 0 (successful).
DEBUG [06e522d5] Running /usr/bin/env [ -f /var/www/repo/HEAD ] on server.xxxxxyyyy.com
DEBUG [06e522d5] Command: [ -f /var/www/repo/HEAD ]
DEBUG [06e522d5] Finished in 0.056 seconds with exit status 0 (successful).
INFO The repository mirror is at /var/www/repo
DEBUG [062dd56a] Running /usr/bin/env if test ! -d /var/www/repo; then echo "Directory does not exist '/var/www/repo'" 1>&2; false; fi on server.xxxxxyyyy.com
DEBUG [062dd56a] Command: if test ! -d /var/www/repo; then echo "Directory does not exist '/var/www/repo'" 1>&2; false; fi
DEBUG [062dd56a] Finished in 0.053 seconds with exit status 0 (successful).
DEBUG [65e9187e] Running /usr/bin/env cd /var/www/repo && git rev-parse --short HEAD on server.xxxxxyyyy.com
DEBUG [65e9187e] Command: cd /var/www/repo && git rev-parse --short HEAD
DEBUG [65e9187e] 69a8427
DEBUG [65e9187e] Finished in 0.080 seconds with exit status 0 (successful).
INFO [349bd507] Running /usr/bin/env git remote update on server.xxxxxyyyy.com
DEBUG [349bd507] Command: cd /var/www/repo && /usr/bin/env git remote update
DEBUG [349bd507] Fetching origin
DEBUG [349bd507] Fetching origin
DEBUG [349bd507] ERROR: Repository not found.
DEBUG [349bd507] Fetching origin
DEBUG [349bd507] fatal: The remote end hung up unexpectedly
DEBUG [349bd507] Fetching origin
DEBUG [349bd507] error: Could not fetch origin
cap aborted!
有什么想法吗?
谢谢,
安迪
【问题讨论】:
标签: git deployment ssh jenkins capistrano