Skip to content

Commit

Permalink
Fix minor ssh issues like stuck pipelines.
Browse files Browse the repository at this point in the history
On hosts without ssh key, the _ssh command was stuck while asking for a password which it never received.
  • Loading branch information
theoriginalgri committed Mar 18, 2023
1 parent 49f621f commit efa9be6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ You need to adjust the paths in `prepare_exec`, `run_exec` and `cleanup_exec` wh

Install dependencies: `brew install gitlab-runner daemonize cirruslabs/cli/tart`.

Ensure your host system has an SSH private key. If not, create one using `ssh-keygen -t ed25519`.

## Configurations
- The image can be selected using Gitlab-CI's `image:` tag. Choose a different tart image, e.g. from https://github.com/orgs/cirruslabs/packages?tab=packages&q=macos. The current default is `ghcr.io/cirruslabs/macos-monterey-xcode:14`.
5 changes: 4 additions & 1 deletion base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ VM_IMAGE="${CUSTOM_ENV_CI_JOB_IMAGE:-$VM_IMAGE_FALLBACK}"
VM_USER="admin"
VM_PASSWORD="admin"

# Load SSH keys from the host.
ssh-add

_get_vm_ip() {
tart ip "$VM_ID" --wait 30 || true
}
Expand All @@ -16,5 +19,5 @@ _get_vm_pid() {
}

_ssh() {
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$VM_USER"@"$VM_IP" "/bin/zsh --login -c '$@'" >/dev/null
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/tmp/$VM_ID "$VM_USER"@"$VM_IP" "/bin/zsh --login -c '$@'" >/dev/null
}

0 comments on commit efa9be6

Please sign in to comment.