4

In order to execute Xamarin Test Cloud tests, you have to execute an appcenter command e.g.

appcenter test run uitest --app "appName" --devices 228faeda --app-path *appPath*  --test-series "master" --locale "en_US" --build-dir *debugFolderPath*

This works perfectly.

I want to trigger this command via Jenkins.

  • I added "Execute Windows batch Command" with the command shown above.

  • I execute the build.

But I get the following error in the Console Output

"C:\Program Files (x86)\Jenkins\workspace\Xamarin Test Cloud Android>appcenter 'appcenter' is not recognized as an internal or external command, operable program or batch file."

Why is that?

Thanks

Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123
user2879680
  • 71
  • 1
  • 5
  • you need to specify the full path to the appcenter exe, or otherwise set an environment variable with the path – Jason Apr 06 '18 at 04:31

1 Answers1

9

Make sure to install the appcenter-cli first.

npm install -g appcenter-cli@1.2.2

Bash Script for App Center Test

Below is the bash script I use for my CI. To implement it, you'll first need to get an authentication token from App Center.

Manually Retrieve an API Token

The App Center CLI requires the user to be logged in, and we can log in from our build server by providing a login token.

Using the App Center CLI, enter the following command, replacing [Name Of Token] with whatever you want to name this token

appcenter login
appcenter tokens create -d "[Name Of Token]"

It will provide a response like this:

ID: [Unique Guid]

API Token: [Unique API Token]

Description: [Name of Token]

Created at: [Time Stamp]

App Center Test CI Script

The bash script does the following:

  1. Locate the UI Test Build Directory
    • Replace [My UI Test Assembly Name] with the name of your UI Test assembly
  2. Locate the APK file
  3. Install the appcenter cli
  4. Log in to App Center using the API Token
    • Replace [login token] with the value of your login token
    • Replace [Your App Center App Name] with the value of your app name
    • Replace [Your Device Id] with the value of your device id
#!/usr/bin/env bash

UITestDLL=`find . -name "[My UI Test Assembly Name].dll" | grep bin`
UITestBuildDir=`dirname $UITestDLL`

APKFile=`find . -name *.apk | head -1`

npm install -g appcenter-cli@1.2.2

appcenter login --token [login token]

appcenter test run uitest --app "[Your App Center App Name]" --devices [Your Device Id] --app-path $APKFile --test-series "master" --locale "en_US" --build-dir $UITestBuildDir --async
Brandon Minnick
  • 13,342
  • 15
  • 65
  • 123