From 22aa8101131dc37b627c1f451c62c0f8e8014618 Mon Sep 17 00:00:00 2001 From: Jim Borden Date: Thu, 31 Oct 2024 20:18:45 -0700 Subject: [PATCH] Fix mistaken Jenkinsfile and add .NET Android pwsh should be shell outside of Windows --- jenkins/pipelines/dotnet/Jenkinsfile | 46 +++++++++++-------- .../pipelines/dotnet}/stop_android.sh | 0 jenkins/pipelines/dotnet/teardown_android.sh | 21 +++++++++ jenkins/pipelines/dotnet/test_android.sh | 25 ++++++++-- 4 files changed, 71 insertions(+), 21 deletions(-) rename {servers/dotnet/scripts => jenkins/pipelines/dotnet}/stop_android.sh (100%) create mode 100755 jenkins/pipelines/dotnet/teardown_android.sh diff --git a/jenkins/pipelines/dotnet/Jenkinsfile b/jenkins/pipelines/dotnet/Jenkinsfile index 5632336b..9b09130c 100644 --- a/jenkins/pipelines/dotnet/Jenkinsfile +++ b/jenkins/pipelines/dotnet/Jenkinsfile @@ -7,7 +7,7 @@ pipeline { string(name: 'SGW_URL', defaultValue: '', description: "The url of Sync Gateway to download") } options { - timeout(time: 30, unit: 'MINUTES') + timeout(time: 120, unit: 'MINUTES') ansiColor('xterm') timestamps() } @@ -38,31 +38,41 @@ pipeline { stage("Mac Catalyst") { agent { label 'mob-e2e-mac-01' } steps { - pwsh "jenkins\\pipelines\\dotnet\\test_mac.sh ${params.CBL_EDITION} ${params.CBL_VERSION} ${params.CBL_BUILD} ${params.SGW_URL}" + shell "jenkins\\pipelines\\dotnet\\test_mac.sh ${params.CBL_EDITION} ${params.CBL_VERSION} ${params.CBL_BUILD} ${params.SGW_URL}" } post { always { - pwsh 'jenkins\\pipelines\\dotnet\\teardown_mac.sh' + shell 'jenkins\\pipelines\\dotnet\\teardown_mac.sh' } } } } } - stage('Mobile') { - parallel { - stage("iOS") { - options { - lock("mob-e2e-iphone-01") - } - agent { label 'mob-e2e-mac-01' } - steps { - pwsh "jenkins\\pipelines\\dotnet\\test_ios.sh ${params.CBL_EDITION} ${params.CBL_VERSION} ${params.CBL_BUILD} ${params.SGW_URL}" - } - post { - always { - pwsh 'jenkins\\pipelines\\dotnet\\teardown_ios.sh' - } - } + stage('iOS') { + options { + lock("mob-e2e-iphone-01") + } + agent { label 'mob-e2e-mac-01' } + steps { + shell "jenkins\\pipelines\\dotnet\\test_ios.sh ${params.CBL_EDITION} ${params.CBL_VERSION} ${params.CBL_BUILD} ${params.SGW_URL}" + } + post { + always { + shell 'jenkins\\pipelines\\dotnet\\teardown_ios.sh' + } + } + } + stage('Android') { + options { + lock("mob-e2e-android-01") + } + agent { label 'mob-e2e-mac-01' } + steps { + shell "jenkins\\pipelines\\dotnet\\test_android.sh ${params.CBL_EDITION} ${params.CBL_VERSION} ${params.CBL_BUILD} ${params.SGW_URL}" + } + post { + always { + shell 'jenkins\\pipelines\\dotnet\\teardown_android.sh' } } } diff --git a/servers/dotnet/scripts/stop_android.sh b/jenkins/pipelines/dotnet/stop_android.sh similarity index 100% rename from servers/dotnet/scripts/stop_android.sh rename to jenkins/pipelines/dotnet/stop_android.sh diff --git a/jenkins/pipelines/dotnet/teardown_android.sh b/jenkins/pipelines/dotnet/teardown_android.sh new file mode 100755 index 00000000..3d39e6a1 --- /dev/null +++ b/jenkins/pipelines/dotnet/teardown_android.sh @@ -0,0 +1,21 @@ +#!/bin/bash -e + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +source $SCRIPT_DIR/test_common.sh +source $SCRIPT_DIR/prepare_env.sh + +banner "Looking up connected Android device" +android_device=$($HOME/.dotnet/tools/xharness android device) +if [ "$android_device" == "" ]; then + echo "Failed to find Android device" + exit 2 +else + echo "Found $android_device" +fi + +banner "Shutdown Test Server for Android" +$SCRIPT_DIR/stop_android.sh $android_device + +banner "Shutdown Environment" +end_tests \ No newline at end of file diff --git a/jenkins/pipelines/dotnet/test_android.sh b/jenkins/pipelines/dotnet/test_android.sh index 04a1067a..45542e1b 100755 --- a/jenkins/pipelines/dotnet/test_android.sh +++ b/jenkins/pipelines/dotnet/test_android.sh @@ -10,14 +10,33 @@ if [ $# -lt 3 ]; then exit 1 fi -#prepare_dotnet +prepare_dotnet modify_package $2 $3 $SCRIPT_DIR/build_android.sh -android_device=$($HOME/.dotnet/tools/xharness android device) || echo "Failed to find Android device"; exit 2 +banner "Looking up connected Android device" +android_device=$($HOME/.dotnet/tools/xharness android device) +if [ "$android_device" == "" ]; then + echo "Failed to find Android device" + exit 2 +else + echo "Found $android_device" +fi + +banner "Resolving Test Server IP" +test_server_ip=$($HOME/.dotnet/tools/xharness android adb -- shell ifconfig wlan0 | grep "inet addr" | awk '{print substr($2, 6)}') +if [ "$test_server_ip" == "" ]; then + echo "Failed to find Android test server..." + exit 2 +else + echo "Resolved to $test_server_ip!" +fi + +my_ip=$(ifconfig en0 | grep "inet " | awk '{print $2}') +echo "Detected TDK client IP as $my_ip" $SCRIPT_DIR/run_android.sh $android_device $SCRIPT_DIR/../shared/setup_backend.sh $sgw_url -begin_tests \ No newline at end of file +begin_tests $test_server_ip $my_ip \ No newline at end of file