Skip to content

Commit a67aee6

Browse files
committed
release.yml: add tmate detached debugging to Mac job
Add a tmate session in detached mode to the Mac build job so that one can SSH into the build agent while the pipeline steps run concurrently. The setup step installs tmate via Homebrew, fetches SSH public keys from the dscho and mjcheetham GitHub profiles to restrict access, then starts tmate in detached mode and prints the SSH connection string. A final step with `condition: always()` waits for the tmate socket to disappear, keeping the agent alive until the user disconnects. This follows the pattern documented in the team's github-action-knowledge- base.md for tmate detached mode inside containers, adapted for Azure Pipelines syntax. Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
1 parent 042625d commit a67aee6

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

.azure-pipelines/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,30 @@ extends:
713713
# locking issues.
714714
set -euo pipefail
715715
sudo mdutil -i off / || true
716+
- script: |
717+
# Install tmate
718+
brew install tmate
719+
720+
# Fetch SSH public keys from GitHub profiles
721+
mkdir -p ~/.ssh &&
722+
curl -sf https://api.github.com/users/dscho/keys >/tmp/github-keys.json &&
723+
curl -sf https://api.github.com/users/mjcheetham/keys >>/tmp/github-keys.json &&
724+
sed -n 's/.*"key": "\(.*\)".*/\1/p' /tmp/github-keys.json >~/.ssh/authorized_keys &&
725+
test -s ~/.ssh/authorized_keys || {
726+
echo "ERROR: no SSH keys found for dscho or mjcheetham" >&2
727+
exit 1
728+
} &&
729+
730+
# Generate an SSH key (needed for tmate)
731+
echo -e 'y\n' | ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa &&
732+
733+
# Start tmate session in detached mode
734+
tmate -S /tmp/tmate.sock -a ~/.ssh/authorized_keys new-session -d &&
735+
tmate -S /tmp/tmate.sock wait tmate-ready &&
736+
737+
# Print SSH invocation
738+
tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}'
739+
displayName: 'Start tmate for debugging (detached)'
716740
- task: Bash@3
717741
displayName: 'Install build dependencies'
718742
inputs:
@@ -744,6 +768,15 @@ extends:
744768
-output libintl.a \
745769
/usr/local/opt/gettext/lib/libintl.a \
746770
/opt/homebrew/opt/gettext/lib/libintl.a
771+
- script: |
772+
PATH="$HOME/bin:$PATH"
773+
while test -e /tmp/tmate.sock
774+
do
775+
tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}'
776+
sleep 5
777+
done
778+
displayName: 'Wait for tmate session to end'
779+
condition: always()
747780
- task: Bash@3
748781
displayName: 'Configure universal build'
749782
inputs:

0 commit comments

Comments
 (0)