使用 ssh 将 codecommit 存储库克隆到 Codebuild 时遇到问题
Trouble cloning a codecommit repository to Codebuild with ssh
我需要从多个 Codecommit 存储库中获取一些文件到 Ubuntu Codebuild 实例中。所以我正在尝试使用 ssh 身份验证克隆 repos。我已经在实例上设置了 ssh 密钥和配置文件,当我执行 git clone
时,问题就来了。我正在使用 expect
来响应第一次 ssh 连接提示。这是我的期望脚本,cloneRepo.sh
:
#!/usr/bin/expect
set timeout 20
spawn git clone
ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/myrepo
/tmp/myrepo
expect "Are you sure you want to continue connecting (yes/no)?" { send
"yes\r" }
expect "Resolving deltas: 100% (*/*), done." {}
interact
当我在 Codebuild 中 运行 一切正常时:
[Container] Running command echo "Cloning Git repositories"
Cloning Git repositories
[Container] Running command sudo ./cloneRepo.sh
spawn git clone ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/myrepo /tmp/myrepo
Cloning into '/tmp/myrepo'...
The authenticity of host 'git-codecommit.us-east-1.amazonaws.com' can't be established.
RSA key fingerprint is a6:9c:7d:bc:35:f5:d4:5f:8b:ba:6f:c8:bc:d4:83:84.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git-codecommit.us-east-1.amazonaws.com' (RSA) to the list of known hosts.
remote:
remote: Counting objects: 0
remote: Counting objects: 40, done.
Receiving objects: 2% (1/40)
...
Receiving objects: 100% (40/40)
Receiving objects: 100% (40/40), 6.66 KiB | 6.66 MiB/s, done.
Resolving deltas: 0% (0/20)
...
Resolving deltas: 100% (20/20), done.
Resolving deltas: 100% (20/20)
但是,/tmp/
仍然是空的:
[Container] Running command ls -la /tmp/
total 8
drwxrwxrwt 2 root root 4096 Aug 1 02:04 .
drwxr-xr-x 22 root root 4096 Aug 1 02:02 ..
它看起来像某种权限错误,但我就是无法确定它。
提前致谢!
我通过在 expect 脚本中的 interact
之前添加 sleep 10
解决了这个问题。
我认为当 expect 脚本结束并且 Codebuild 继续 运行 时,克隆过程并没有完全完成。添加暂停允许克隆完成。
我需要从多个 Codecommit 存储库中获取一些文件到 Ubuntu Codebuild 实例中。所以我正在尝试使用 ssh 身份验证克隆 repos。我已经在实例上设置了 ssh 密钥和配置文件,当我执行 git clone
时,问题就来了。我正在使用 expect
来响应第一次 ssh 连接提示。这是我的期望脚本,cloneRepo.sh
:
#!/usr/bin/expect
set timeout 20
spawn git clone ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/myrepo /tmp/myrepo
expect "Are you sure you want to continue connecting (yes/no)?" { send "yes\r" }
expect "Resolving deltas: 100% (*/*), done." {}
interact
当我在 Codebuild 中 运行 一切正常时:
[Container] Running command echo "Cloning Git repositories"
Cloning Git repositories[Container] Running command sudo ./cloneRepo.sh
spawn git clone ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/myrepo /tmp/myrepo
Cloning into '/tmp/myrepo'...
The authenticity of host 'git-codecommit.us-east-1.amazonaws.com' can't be established.
RSA key fingerprint is a6:9c:7d:bc:35:f5:d4:5f:8b:ba:6f:c8:bc:d4:83:84.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git-codecommit.us-east-1.amazonaws.com' (RSA) to the list of known hosts.remote:
remote: Counting objects: 0
remote: Counting objects: 40, done.
Receiving objects: 2% (1/40)
...
Receiving objects: 100% (40/40)
Receiving objects: 100% (40/40), 6.66 KiB | 6.66 MiB/s, done.
Resolving deltas: 0% (0/20)
...
Resolving deltas: 100% (20/20), done.
Resolving deltas: 100% (20/20)
但是,/tmp/
仍然是空的:
[Container] Running command ls -la /tmp/
total 8
drwxrwxrwt 2 root root 4096 Aug 1 02:04 .
drwxr-xr-x 22 root root 4096 Aug 1 02:02 ..
它看起来像某种权限错误,但我就是无法确定它。
提前致谢!
我通过在 expect 脚本中的 interact
之前添加 sleep 10
解决了这个问题。
我认为当 expect 脚本结束并且 Codebuild 继续 运行 时,克隆过程并没有完全完成。添加暂停允许克隆完成。