Tuesday 8 August 2023

Jenkins - Build Steps - Execute Windows batch command - pytest

::echo off

echo test_product=%test_product%

echo test_env=%test_env%

echo list_devices=[%list_devices%]

echo total iteration=%ota_iterations%

echo total max attempts=%ota_max_attempt%

set test1=KPI_Scripts\UbiCell\%KPM_Tests%

echo test1=%test1%

echo is_test_result_to_be_uploaded_on_cloud=%is_test_result_to_be_uploaded_on_cloud%

pytest %test1% -n=%NumberOfThreadsForOTAIterations% --junitxml="./Reports/reports.xml" --html="./Reports/reports.html" 

Jenkins Groovy Function To Be Used by Active Choice Parameter - To Have Auto Selected Based On Certain Logic

 

Jenkins Groovy Function To Be Used by Active Choice Parameter - To Have Auto Selected Based On Certain Logic

def get_list(x,delimiter,item_to_be_selected,bool_is_selected=false) {

    list_selected = null

    if(x!=null && x.length() > 0) {

        list = x.split(delimiter)

        list_selected = []

        for(int i=0;i<list.size();i++){

            if(bool_is_selected){

                if(list[i].trim().equals(item_to_be_selected)){

                     list_selected[i] = list[i].trim() + ':selected'

                    

                    }

                else {

                    list_selected[i] = list[i].trim()

                }

            }

            else {

                list_selected[i] = list[i].trim()

            }

            

        }

       

    }

     return list_selected

}


Calling the function - return get_list(list_ota_servers,'-','t:98,d:http://updqa4.ubicquia.com',true)