summaryrefslogtreecommitdiff
path: root/jenkins-helpers.sh
diff options
context:
space:
mode:
Diffstat (limited to 'jenkins-helpers.sh')
-rw-r--r--jenkins-helpers.sh31
1 files changed, 14 insertions, 17 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh
index f274e890..4e0ad8ff 100644
--- a/jenkins-helpers.sh
+++ b/jenkins-helpers.sh
@@ -160,30 +160,27 @@ print_hw_id_for_node ()
}
# $1: Jenkins $NODE_NAME
-# Prints DNS hostname
+# Prints SSH host
print_host_for_node ()
{
(
set -euf -o pipefail
- # We first check if $1 is known by the DNS inside .tcwglab. If
- # not, it might be an external machine for which we have
- # configured ssh
- local host="$1.tcwglab"
-
- # Map tcwg-x86_64-build-* and tcwg-x86_64-dev-* to build-* and dev-*
- case "$host" in
- tcwg-x86_64-*) host=${host#tcwg-x86_64-} ;;
- esac
+ local host
- if ! host "$host" >& /dev/null; then
- # No DNS entry, try to see if it is handled by our ssh config
- if ! ssh "$1" true >& /dev/null; then
- echo "Error: no DNS entry and no SSH configuration for $host" >&2
- exit 1
- else
- host="$1"
+ # All jenkins nodes have either <NODE> or <NODE>.tcwglab entry in
+ # .ssh/config (in dockerfiles.git/tcwg-base/tcwg-buildslave/).
+ for suffix in "" ".tcwglab"; do
+ host="$1$suffix"
+ if timeout 30s ssh "$host" true >& /dev/null; then
+ break
fi
+ host=""
+ done
+
+ if [ x"$host" = x"" ]; then
+ echo "Error: print_host_for_node() cannot ssh to $1 or $1.tcwglab" >&2
+ exit 1
fi
echo "$host"