Running Tests using Jenkins
  • 29 Mar 2023
  • 4 Minutes to read
  • Dark

Running Tests using Jenkins

  • Dark

Article summary


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

  1. Go to Dashboard and Click on New Item
  2. Enter “project name”, select “Freestyle project” and click “OK”
  3. Under General scroll down and Go to Build and click on the Add build step
  4. Select "Execute Windows batch command" for windows or Execute Shell from the drop-down

Note: This needs to be selected depending on OS

  1. 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

  1. Set app capability
    **Steps to Set App Capability **
    1. Login to your registered account.
    2. On the "Start page" navigate to "Capabilities" in the tools section.
    3. On the Capabilities Configurator Page, you can select OS and the Automation Type.
    4. Next, you can you can enable different capabilites like Capturing Logs, Enabling local testing or Wildnet, Capturing Video, and capturing Performance Data.
    5. Next, you can you can enter the Device Details such as region, Device Full name, Manufacturer or Device Version.
    6. 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 you 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.
    7. 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 section. The app package and activity.
    8. Click on Generate Capabilites, once all the details are filled in.
    9. The Capabilities will get generated according to the details and specifications that the user mentions. A success notification will appear as well.
    10. Now you can simply click on the Copy icon to copy the Capabilites and paste it in your appium script and execute the program.
    11. To startover for a different specification or scenario, simply hit the reset button on the bottom and follow the same steps mentioned above.
  2. Click on "Build Now" and go to console output to check the status.
  3. Click on “Console Output

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


  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
  1. Login into your Jenkins and click on “New Item”
  2. Enter the Project name and Select pipeline style.
  3. 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. In the “sample step” select the “Git” option from the dropdown.
      • Enter the repository URL from GitHub.
      • Enter the branch name
      • Configure GitHub credentials in Jenkins

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

  1. Click on Generate pipeline script.

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

  1. Go to the Dashboard and click on the created build and select configure
  2. Write the code to run the pipeline script and click on SAVE
pipeline {
agent any
stages {
stage('Clonning Git') {
steps {
git credentialsId: '', url: ''
stage('Authentication') {
steps {
script {
env.authtoken = sh( script: "curl -u : | 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"
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
    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.

  1. Run the build.

Was this article helpful?

What's Next