Travis CI integration with TestGrid

You are here:
< All Topics

Travis CI is a popular continuous integration service that allows you to automatically build, test, and deploy your projects. Here’s how you can set up Travis CI for a Java TestNG or any project:

  1. Create a Travis CI Account:
    If you don’t have a Travis CI account, sign up for one at https://travis-ci.org/ using your GitHub account or others bitbucket and other project manager tools.
  2. Enable Your Repository:
    Once you’re logged in, go to your Travis CI dashboard and enable the repository where your Java TestNG or other projects are hosted. You can do this by flipping the switch next to your repository name.

 

 

  1. Add a .travis.yml File:
    Create a file named .travis.yml in the root directory of your project. This file contains the configuration for Travis CI.

 

Example of .travis.yml file.

language: java

jdk:
  - openjdk8

install: true

script:
  - mvn clean test

 

This example configuration sets the language to Java, specifies that OpenJDK8 of later should be used, and defines a script to run Maven to clean and execute your TestNG tests.

  1. Configure:
    Ensure that your project type configuration is set up properly. You should have a configuration file in your project directory with the necessary dependencies.

 

  1. Commit and Push:
    Commit the .travis.yml file and your project’s code to your repository.

 

  1. Monitor the Build:
    Travis CI will automatically pick up the changes in your repository and start building your project. You can monitor the build progress on the Travis CI dashboard.

 

  1. View Build Logs:
    Once the build is complete, you can view the build logs to see the output of the project builds. If there are any failures, you can debug them using the information provided in the logs.

 

  1. Optional Steps:
    • You can customize your .travis.yml file to include additional steps, such as deploying your project or sending notifications on build status.
    • If you need environment variables, you can define them in the Travis CI dashboard and use them in your .travis.yml file.

 

Below is the configuration references for your project acordingly.

To use the curl command in your .travis.yml file to trigger a build, you’ll need to include it as a script step in your build configuration. Here’s how you can set it up:

  1. Update Your .travis.yml File:
    Add the following script step to your .travis.yml file. for example:

 

language: bash

script:
  - curl --location 'https://public2.testgrid.io.testgrid.io/ci/' \
    --form 'user_token="ochskrxwei4ujverxb8w5jfxj1bgnlsw"' \
    --form 'application_token="2ba28a34c43f9a5bfd1a51d8f2773e4d"' \
    --form 'version_token="594654a28ce4a04ae17aed1c273b8c88"' \
    --form 'process_type="ow"' \
    --form 's_device="86ILTP"' \
    --form 'test_webstie_url="https://demoqa.com/"' \
    --form 'version_module_id="7"'

 

Selenium Web With Website URL

  • Syntax:
curl --location 'https://{your_domain}.testgrid.io/ci/app_build_run' \
--form 'application_token='a46e4ad3e18e880a4bcss50c05df66ef3c'' \
--form 'user_token='ochskrxwei4ujsssverxb8w5jfxj1bgnlsw'' \
--form 'version_token='34c4511734ed6a1bf7fe1a642deass0115'' \
--form 'version_module_id='15'' \
--form 's_device='QF37N5A'' \
--form 'process_type='ow'' \
--form 'test_website_url='https://www.google.com''

 

Appium With Mobile Application File and Bundle Identifier

process_type (Android – Appium) oaa
process_type (Web) ow
process_type (iOS- Appium) oia

 

Syntax with Build_id:

curl --location 'https://{your_domain}.testgrid.io/ci/app_build_run' \
--form 'application_token='a46e4ad3se18e880a4bc50aac05df66ef3c'' \
--form 'user_token='ochskrxwei4ujssverxb8w5jfxj1bgnlsw'' \
--form 'version_token='34sc4511734ed6a1bf7fe1ass642dea0115'' \
--form 'version_module_id='16'' \
--form 's_device='QF38N5U'' \
--form 'process_type='oaa'' \
--form 'app_build_id='27'' \

Syntax with Bundle Identifier:

curl --location 'https://{your_domain}.testgrid.io/ci/app_build_run' \
--form 'application_token='a46e4ad3se18e880a4bc50aac05df66ef3c'' \
--form 'user_token='ochskrxwei4ujssverxb8w5jfxj1bgnlsw'' \
--form 'version_token='34sc4511734ed6a1bf7fe1ass642dea0115'' \
--form 'version_module_id='16'' \
--form 's_device='QF38N5U'' \
--form 'process_type='oaa'' \
--form 'bundle_identifier='Your_Bundle_id''

 

The location of the configuration command is referenced.

This script checks if the build is running on the master branch and is not a pull request. If these conditions are met, it triggers a new build using the curl command.

When Travis CI runs a build, it will execute the script section in your .travis.yml file. The curl command within the script section will trigger a new build on the master branch using the Travis CI API.

Now click Dashboard to activate your button by clicking the “Trigger Build” button.

Once build successfully done you can check “More Options“ and view it.

 

 

Once you have the build_id, you must check the execution of our testgrid platform.

On the TestGrid Automation Dashboard, keep an eye on and analyze your test results.

In order to give all of your visitors a seamless user experience, deploy your code in a dependable way at scale using Travis CI integration with TestGrid and make sure it looks robust across all browsers and devices.

Happy Testing! 😁.

Table of Contents