I need to get some files from multiple Codecommit repositories onto an Ubuntu Codebuild instance. So I'm trying to clone the repos using ssh authentication. I've already set up the ssh keys and the config file on the instance, the trouble comes up when I do a git clone
. I'm using expect
to respond to the first time ssh connection prompt. Here's my expect script, 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
Everything looks okay when I run it in 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)
However, /tmp/
remains empty:
[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 ..
It looks like some sort of permissions error, but I just can't put my finger on it.
Thanks in advance!
exp_internal 1
beforespawn
and see if there's anything wrong. – pynexj