0

Inside my androidTest I create a custom text file

File dir = new File(Environment.getExternalStorageDirectory() + "/TestResults");
    logFile = new File(dir.getAbsolutePath() + "result.txt");

    if (!logFile.exists())
    {
        try
        {
            dir.mkdirs();
            logFile.createNewFile();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }

and during the test run I write some custom data there. When I run test locally on the emulator, I can see the file created and I can pull it using

enter image description here

adb pull /sdcard/TestResults/result.txt

But when I run the same test inside Jenkins build step

echo pulling test result file
cd %LocalDir%\Android\sdk\platform-tools

adb.exe pull /sdcard/TestResults/result.txt D:\ANDROID_TEST_DATA\ 

and try to pull the file, I get:

pulling test result file    
adb: error: remote object '/sdcard/TestResults/result.txt' does not exist
    Build step 'Execute Windows batch command' marked build as failure
    [android] Stopping Android emulator

Any ideas, how this could be fixed?

Update

Also tried paths:

/storage/emulated/0/TestResults/result.txt
/mnt/sdcard/TestResults/result.txt
insomnium_
  • 1,800
  • 4
  • 23
  • 39

1 Answers1

0

try this instead:

adb.exe pull /mnt/sdcard/TestResults/result.txt D:\ANDROID_TEST_DATA\ 
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • @insomnium_ guess you'd have to launch the `cmd` with `Run as Administrator` (as a manual test, to ensure to path would work with elevated permissions). – Martin Zeitler Sep 12 '18 at 13:28
  • and then see https://stackoverflow.com/questions/27413261/run-batch-file-as-administrator-on-jenkins – Martin Zeitler Sep 12 '18 at 13:29