Greenspector Documentation has been moved.
Please go to

https://greenspectorstudio.atlassian.net/l/cp/TDhqYDSu

Jenkins

TO UPDATE

You can use Jenkins to launch your GREENSPECTOR Tests to measure your website or your mobile app.

Requirements

You need to install the GREENSPECTOR CLI on your Jenkins server

  • The GREENSPECTOR CLI file could be downloaded from the Modules page of your GREENSPECTOR Web Interface. You have to choose the executable which match your server OS.
  • Connect to your Jenkins server through ssh or ftp
  • Upload the GREENSPECTOR CLI on your Jenkins server and Slaves if any
  • Prefer to rename the file in gspt
  • For linux or mac environment, you need to give right of execution : chmod +x gspt
  • Prefer to put it in your path


How to launch measures on your website or your mobile application every day

1 - Create an application on your GREENSPECTOR Web Interface

Choose what you want to measure, your website or your mobile application.

In our tutorial we choose to measure the GREENSPECTOR institutional website https://greenspector.com/en/home/ so we call the application 'greenspector.com'



2 - Create a Freestyle project on your Jenkins interface


3 - Configure the trigger of your freestyle project

You can choose when the project is triggered. In our example we choose every morning at 3 am


4 - Make a secret with your private Token

You can get your private Token on the GREENSPECTOR Web Interface in your preference page.

This private token is used by the command line tools Greenspector CLI to communicate with GREENSPECTOR API.


In the page configuration of your Jenkins freestyle project, go to the Build Environment block and choose "Use secret text(s) or file(s)". Choose a name for your new secret (for example MY_GREENSPECTOR_PRIVATE_TOKEN)

Then Add a new credential (Put the token in the secret field)


5 - Configure the Build

On the "Build" block of your Jenkins configuration page, add a 'build step' of type 'Execute shell.


6 - Configure the 'Execute shell' step :

You have to use the GREENSPECTOR CLI commands to configure the measure to launch. If you need more detail click on GREENSPECTOR CLI .

In the 'Execute shell' block, you have to do :

  • Set your GREENSPECTOR instance and token. Use the secret you have previously configured.
    gspt init -a https://app.greenspector.com/api -p $MY_GREENSPECTOR_PRIVATE_TOKEN
  • Set the GREENSPECTOR application and version in which you want to send measures. We set, for the version, the date of the day but you can use any build number of your application.
    gspt initprojectconfiguration --application "greenspector.com" --version "$(date '+%d-%m-%Y')"
  • Set the device on which the measures will be launched. For example a Galaxy S7.

    gspt testbench set-environment --environment "mobile::android::8::Samsung - Galaxy S7"

    To have a list of all available devices on which you can send measures, you can use the GREENSPECTOR CLI on your PC for example :

    The command 'gspt testbench set-environment ' gives the list 


Then you have to replace the android version and the device name in the previous command. For example to send measure on Galaxy S9 android 10 ,

gspt testbench set-environment --environment "mobile::android::10::Samsung - Galaxy S9"

7 - Choose what you want to measure

You can decide to run a benchmark test of your web site, run a benchmark test of your mobile application or run a custom test with your GDSL script of your web site or mobile application

7 - 1 - Benchmark website

# launch 3 iterations of a benchmark on the site web
gspt --spinnerOff testbench measure-url --iterations 3 --url https://greenspector.com/fr/accueil/

Summary example of a benchmark of a website :

7 - 2 - Benchmark mobile application

To launch 3 iterations of benchmark for your mobile application

If your application is already installed on the phone or is available on PlayStore, you need to precise the package name. For example, with this we launch 3 iterations on the application Netflix.

gspt --spinnerOff testbench benchmark-apk --apkFile "com.netflix.mediaclient" --iterations 3


In other case, you need to pass an apk via a public url or an url accessible by your jenkins

gspt --spinnerOff testbench benchmark-apk --apkFile https://dl.greenspector.com/demo/demo.apk --iterations 3


Or to pass an apk via an absolute PATH in JENKINS or relative PATH in your freestyle project

gspt --spinnerOff testbench benchmark-apk --apkFile ./demo.apk --iterations 3


Summary example of a benchmark of a mobile application :

7 - 3 - Launch custom tests written with GDSL

To launch 3 iterations of a custom test :

# Path to your GDSL script in the working directory
PWD=$(pwd)
TEST_SUITE1="$PWD/greenspector-site.testgb"

# launch a custom test with your gdsl script
gspt --spinnerOff testbench custom-tests --monitoredPackage com.android.chrome --iterations 3 --testsSuite "suite1:$TEST_SUITE1" --networkMode WIFI 


  • You should set the monitoredPackage argument.

if your script is about the measurement of a website, you should set the package of Chrome to monitore : --monitoredPackage com.android.chrome

If your script is about the measurement of a mobile application, you should set the package name of the mobile app to monitore : --monitoredPackage com.netflix.mediaclient


  • You probably need to import the GDSL script in the working directory of your freestyle project.

The easiest way is to configure the "source Code Management" block with a git project which contains your GDSL files


Summary example of a custom test :

8 - Tests Tracking

When your freestyle project as build, a test has been scheduled. To follow the progress, you can go to the page 'Test tracking' of your GREENSPECTOR Web Interface


9 - Results

When the test is finished, you can consult the Test Results tab to see if all the tests are passed :


If the test launch is a benchmark, you can go to the 'Dashboard' tab :


You can view all the measures :


You can view the evolution for each version :