= Running Tests using Jenkins - pCloudy documentation

Running Tests using Jenkins


Jenkins is an open-source continuous integration/continuous delivery and deployment (CI/CD) automation software DevOps tool. It is used to implement CI/CD workflows, called pipelines. Users can use Jenkins to execute automation on the pCloudy platform to enable CI/CD.


  • The user should be registered on the pCloudy platform
  • Jenkins installed on the local machine
  • Maven and JDK path should be configured in Jenkins
  • Maven should be installed on the local machine
  • Set the required capabilities in the Appium script
  • Copy the project path and keep it handy

Let's see the Approaches

  1. Freestyle
  2. Pipeline

Steps to run jenkins using the Freestyle approach

Steps 1. Go to Dashboard and Click on New Item

manage jenkins

Steps 2. Enter “project name”, select “Freestyle project” and click “OK”

manage plugins

Steps 3. Under General scroll down and Go to Build and click on the Add build step

Advanced Tab

Steps 4. Select "Execute Windows batch command" for windows or Execute Shell from the drop-down

Note: This needs to be selected depending on OS

upload plugin

Steps 5. Enter the maven command to run the project and save it

Note: Here user needs to give the path of the project where it is located

e.g. cd C:\Users\Admin\eclipse-workspace\Chapter4-TestNgwithpCloudyonSingleDeviceIOS2

mvn test

Note: Make sure pCloudy capabilities should be set in Runner.java

upload plugin

Steps 6. Set app capability

Note - The steps to generate Capabilties are a bit different for both the New and Old User Interface, please scroll down further to view the steps on the Old UI.

Let's see the steps to follow in the New UI

  • Login to your registered account.
  • On the "Start page" navigate to "Capabilities" in the tools section as shown in below screenshot.
  • capability-configurator
  • On the Capabilities Configurator Page, you can select OS and the Automation Type.
  • capability-configurator
  • Next, you can you can enable different capabilites like Capturing Logs, Enabling local testing or Wildnet, Capturing Video, and capturing Performance Data.
  • capability-configurator
  • Next, you can you can enter the Device Details such as region, Device Full name, Manufacturer or Device Version.
  • You can select the Device Full Name from the drop down of available devices. However, it is advisable to select the Device Manufacturer and Version instead of the full name of the device to avoid failure of execution due to non-availability of a specific device that yu might select in the Device Full name field. Providing a Device Manufacture and Version, gives you a broader reach when your script starts to look for available devices on the platform.
  • capability-configurator
  • Once you have selected the Device Details, simply fill in the Duration of the execution in mins, selection the App from the drop down, please ensure that you have uploaded the app beforehand on the My Data. The app package and activity.
  • capability-configurator
  • Click on Generate Capabilites, once all the details are filled in.
  • The Capabilities will get generated according to the details and specifications that the user mentions. A success notification will appear as well.
  • capability-configurator
  • Now you can simply click on the Copy icon to copy the Capabilites and paste it in your appium script and execute the program.
  • To startover for a different specification or scenario, simply hit the reset button on the bottom and follow the same steps as mentioned above.
  • capability-configurator

Let's see the steps to follow in the Old UI

  • Login to your registered account.
  • Go to the "Device page" and navigate to the "Capabilities" section as shown in the below screenshot. You will see "Capability Configurator"
  • Select Operating System->Android or iOS
  • Select Automation Type->Browser Testing or App Testing
  • Note: As per Automation Type selection other fields get updated.

E.g.: If user selects OS as "Android" and Automation Type as "App Testing"

upload plugin
  • Application Name :-This is an optional field.
    • Note: We kept it option as for preinstalled app,app name not required
  • App Package :-
    • In very basic terms, appPackage is the technical name of the app which is provided by its developers
  • App Activity :-
    • AppActivity refers to the different functionalities that are provided by the app.
    • For example, WhatsApp provides multiple functionalities such as conversations, profile information, setting profile photos, setting status, notifications and a lot of other things. All these functionalities are represented by different appActivity

Note: You can find AppPackage and App Activity by :-

  • Using 'mCurrentFocus' or 'mFocusedApp' in Command Prompt. For this adb needs to be installed in your system.
  • Using APK Info app:- APK Info is an app that you can download from Play Store, and it will provide the app package and app activity name of any app which is installed on your mobile device.

Refer: capability-configurator for more detailed information about all use cases

Steps 7. Click on "Build Now" and go to console output to check the status

upload plugin

Steps 8. Click on “Console Output”

select new item select new item

Steps to run jenkins using the Pipeline approach


  • Install jq package (This package helps to get the output response)
  • jq is like sed for JSON data – you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text. It is written in portable C.
  • Maven should be configured in Jenkins
  • User should have a Github account: this is needed incase if the repository is private

Note: This sample project is for reference with respect to the ubuntu machine

Steps 1: Create a GitHub account and upload your project


  • For the public repository, users don't need to configure Github in Jenkins
  • For a private repository, users need to configure Github in Jenkins

Steps 2: Login into your Jenkins and click on “New Item”

enter a name for project

Steps 3: Enter the Project name and Select pipeline style.

navigate to build

Steps 4: If the Project in Github is private, then the user needs to configure Github credentials in Jenkins

Steps to access Github from Jenkins:-

  1. once the build is created, go to the Jenkins dashboard and click on pipeline syntax to configure GitHub credentials
  2. enter a name for project
    1. In the “sample step” select the “Git” option from the dropdown.
    2. Enter the repository URL from GitHub.
    3. Enter the branch name
    4. Configure GitHub credentials in Jenkins
    5. enter a name for project

      Note: If Git is not working from the password, generate a git token from GitHub and place it in the password field.

    6. Click on Generate pipeline script.
    7. enter a name for project

      Note: Above process is used to clone the Git repository to the Jenkins workspace.

Steps 5: Go to the Dashboard and click on the created build and select configure

enter a name for project

Steps 6: Write the code to run the pipeline script and click on SAVE

pipeline {
agent any
stages {
stage('Clonning Git') {
steps {
git credentialsId: '', url: 'https://github.com/satyamraii/pCloudySample.git'
stage('Authentication') {
steps {
script {
env.authtoken = sh( script: "curl -u : https://device.pcloudy.com/api/access | jq -r .result.token",returnStdout: true).trim()
echo "My authotoken: ${env.authtoken}"
stage('UploadFile') {
steps {
sh "curl -X POST -F file= -F source_type=raw -F token=${env.authtoken} -F filter=all https://device.pcloudy.com/api/upload_file"
stage('runtestcases') {
steps {
sh "mvn test"

Code definition:- There are four stages as mentioned below:-

  • Jenkins stage 1:- Git clone-> For example, we have considered pCloudy-sample-project chapter-1: Which is for a single device(Android)

    Here is a reference link for the same.

    Note:- We have updated the capabilities in GitHub as well.

  • Jenkins stage 2:- In this stage, we are using the authentication API which is present in content.pcloudy.com

    Here the user needs to enter the email and API key to generate the token.

    Note:- The user can also use the Jq package to help extract the token value from the output

  • Jenkins stage:- 3 Upload stage-> The user needs to enter the local file path in the API
  • Jenkins stage:- 4 Run mvn test.
enter a name for project

Steps 7: Run the build.