From 6c1a3f85a6e4d15399c6232c186f6f4783f48d0f Mon Sep 17 00:00:00 2001 From: Jian Chen Date: Thu, 22 Aug 2024 10:18:01 -0700 Subject: [PATCH] Do not allow clearing Android logs if the emulator is not running (#21578) ### Description Do not allow clearing Android logs if the emulator is not running ### Motivation and Context Previously the Clearing Android logs step stuck until the pipeline timeout. If one of the previous steps failed. --- .../templates/android-dump-logs-from-steps.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/templates/android-dump-logs-from-steps.yml b/tools/ci_build/github/azure-pipelines/templates/android-dump-logs-from-steps.yml index 212924d6951..2d91c605bf3 100644 --- a/tools/ci_build/github/azure-pipelines/templates/android-dump-logs-from-steps.yml +++ b/tools/ci_build/github/azure-pipelines/templates/android-dump-logs-from-steps.yml @@ -5,12 +5,23 @@ parameters: type: stepList steps: +- task: CmdLine@2 + input: + script: | + if [ -f $(Build.BinariesDirectory)/emulator.pid ]; then + echo "Emulator is running." + echo "##vso[task.setvariable variable=isEmulatorRunning]True" + else + echo "Emulator is not running." + fi + name: Determine if emulator is running + - task: CmdLine@2 inputs: script: | python3 tools/python/run_adb.py logcat --clear displayName: "Clear Android logs" - condition: succeededOrFailed() + condition: eq(variables['isEmulatorRunning'], 'True') - ${{ parameters.steps }} @@ -19,4 +30,4 @@ steps: script: | python3 tools/python/run_adb.py logcat -d displayName: "Dump Android logs" - condition: succeededOrFailed() + condition: eq(variables['isEmulatorRunning'], 'True')