Code Monkey home page Code Monkey logo

pytest-jenkins's Introduction

How to integrate Jenkins pipeline for Pytest on LambdaTest

Jenkins Pipeline is also referred to as "Pipeline" offers a suite of plugins to help integrate your continuous delivery pipeline into Jenkins. Jenkins Pipeline does so with the help of Pipeline DSL(Domain Specific Language) syntax that facilitates easy modelling of even the most complex delivery pipeline.

You can easily create a Jenkins pipeline for Pytest automation tests on LambdaTest using the following steps. You can refer to sample test repo here.

Prerequisites For Configuring Jenkins Pipeline With LambdaTest

  1. Jenkins 2.X or greater version.
  2. A Jenkins User with root access.
  3. Ensure you have the Pipeline plugin, although, it is displayed under the "suggested plugins" during the post-installation setup of Jenkins.
  4. LambdaTest Authentication Credentials Be aware of your LambdaTest authentication credentials i.e. your LambdaTest username, access key and HubURL. You need to set them up as your environment variables. You can retrieve them from your LambdaTest automation dashboard by clicking on the key icon near the help button.
  • For Linux/Mac:

    $ export LT_USERNAME= {YOUR_LAMBDATEST_USERNAME}$ export LT_ACCESS_KEY= {YOUR_LAMBDATEST_ACCESS_KEY}
    
  • For Windows:

    $ set LT_USERNAME= {YOUR_LAMBDATEST_USERNAME}$ set LT_ACCESS_KEY= {YOUR_LAMBDATEST_ACCESS_KEY}
    

Setting Up Jenkins Pipeline

Find the code for setting up a pipeline for the sample Pytest repo.

pipline 
{
    withEnv(["LT_USERNAME=Your LambdaTest UserName",
    "LT_ACCESS_KEY=Your LambdaTest Access Key",
    "LT_TUNNEL=true"]){

    echo env.LT_USERNAME
    echo env.LT_ACCESS_KEY 

    stages{
        stage('setup') { 

            // Get some code from a GitHub repository
            try{
            git 'https://github.com/LambdaTest/pytest-selenium-sample'

            //Download Tunnel Binary
            sh "wget https://s3.amazonaws.com/lambda-tunnel/LT_Linux.zip"

            //Required if unzip is not installed
            sh 'sudo apt-get install --no-act unzip'
            sh 'unzip -o LT_Linux.zip'

            //Starting Tunnel Process 
            sh "./LT -user ${env.LT_USERNAME} -key ${env.LT_ACCESS_KEY} &"
            sh  "rm -rf LT_Linux.zip"
            }
            catch (err){
            echo err
        }

        }
        stage('build') {
            // Installing Dependencies
            sh 'pip install -r requirements.txt'
            }

        stage('test') {
                try{
                sh 'python tests/lt_sample_to.py'
                }
                catch (err){
                echo err
                }  
        }
        stage('end') {  
            echo "Success" 
            }
        }
    }
}

You can now add this script when creating the pipeline by using the following steps:

  1. Create new pipleline
  2. Scroll down to Advanced Project Options.
  3. Paste the Code in the code pane or fetch it via SCM & hit the Save button.

Note: To run on the tunnel, Either you can use LT_TUNNEL Environment variable to set the tunnelling capability or you can pass in the code. Instructions on the tunnel are are available in the sample repo readme.

Links:

LambdaTest Community

pytest-jenkins's People

Contributors

riadayal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.