SauceLabs Plugin for Android

Upload APKs directly to SauceLabs and run test scripts using this gradle plugin

License

License

Categories

Categories

Gradle Build Tools Square Business Logic Libraries Financial
GroupId

GroupId

com.ms-square
ArtifactId

ArtifactId

saucelabs-gradle-plugin
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

SauceLabs Plugin for Android
Upload APKs directly to SauceLabs and run test scripts using this gradle plugin
Project URL

Project URL

https://github.com/Manabu-GT/saucelabs-gradle-plugin
Source Code Management

Source Code Management

https://github.com/Manabu-GT/saucelabs-gradle-plugin

Download saucelabs-gradle-plugin

How to add to project

<!-- https://jarcasting.com/artifacts/com.ms-square/saucelabs-gradle-plugin/ -->
<dependency>
    <groupId>com.ms-square</groupId>
    <artifactId>saucelabs-gradle-plugin</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.ms-square/saucelabs-gradle-plugin/
implementation 'com.ms-square:saucelabs-gradle-plugin:1.0.0'
// https://jarcasting.com/artifacts/com.ms-square/saucelabs-gradle-plugin/
implementation ("com.ms-square:saucelabs-gradle-plugin:1.0.0")
'com.ms-square:saucelabs-gradle-plugin:jar:1.0.0'
<dependency org="com.ms-square" name="saucelabs-gradle-plugin" rev="1.0.0">
  <artifact name="saucelabs-gradle-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.ms-square', module='saucelabs-gradle-plugin', version='1.0.0')
)
libraryDependencies += "com.ms-square" % "saucelabs-gradle-plugin" % "1.0.0"
[com.ms-square/saucelabs-gradle-plugin "1.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.apache.httpcomponents : httpmime jar 4.4
commons-io : commons-io jar 2.4

Project Modules

There are no modules declared in this project.

SauceLabs Gradle Plugin for Android

Build Status Sauce Test Status

This plugin integrates SauceLabs platform with the Gradle build system. With this plugin, you can upload your APK to Sauce Labs and run test script directly via Android Studio or command line.

Compatibility

Currently verified to work with Gradle 2.2.1, Android Gradle Plugin 1.1.3, and Android Studio 1.1.0

Installation

A SauceLabs Gradle Plugin is pushed to Maven Central, so installation consists of adding the following to your build.gradle file:

  1. Add plugin dependency:

    classpath 'com.ms-square:saucelabs-gradle-plugin:1.0.0'
    
  2. Apply plugin:

    apply plugin: 'saucelabs'
    
  3. Configure your sauce labs credentials:

    # Make sure SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are set
    export SAUCE_USERNAME=<your saucelabs username>
    export SAUCE_ACCESS_KEY=<your saucelabs accessKey>
    

Complete Example

For convenience, here is a snippet of a complete build.gradle file, including the additions above.

apply plugin: 'com.android.application'
apply plugin: 'saucelabs'

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.3'

        classpath 'com.ms-square:saucelabs-gradle-plugin:1.0.0'
    }
}

Usage

With the plugin installed, a set of new tasks, prefixed "sauceLabs" will be added, one for each build type.

For example: to upload a debug build and test on SauceLabs, run the following from terminal:

./gradlew sauceLabsDebug

Parameters

android {
    sauceLabsConfig {
        userName "foo" (optional, defaults to SAUCE_USERNAME environment variable)
        accessKey "hoge" (optional, defaults to SAUCE_ACCESS_KEY environment variable)
        overwrite true (optional, defaults to true)
        testCommand "py.test sample/appium/android_sauce_labs.py" (required, your test script)
    }
}

By setting the overwrite to true, the plugin will overwrite the apk file already stored in Sauce temporary storage. It is the default behavior of the Sauce Labs Upload API.

Injected Environment variables

The plugin will inject the following environment variables and make them available to your test script.

  • SAUCE_COMMIT - Git commit hash that the current build is testing.
  • SAUCE_APK_FILE - APK file name uploaded to the sauce labs.
  • SAUCE_APK_VERSION_NAME - Android application version name in the manifest.
  • SAUCE_APK_VERSION_CODE - Android application version code in the manifest.

For its sample usage, please look at the test code of the provided sample.

License

 Copyright 2015 Manabu Shimobe

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

Versions

Version
1.0.0