Jenkins Job for Scriptless Test Case

  • From Jenkins, select option “New Item” and specify name of the job to be created and select “OK”. 
  • Click on newly created Jenkins job and click on Configure option. Job configuration can be edited now.

Configure Build Parameters

In General section

    • Check the “Discard old builds”.
    • Select Log Rotation and we can keep the days of build and Max # of builds.
    • Check the "This project is parameterized".

Please configure following String build parameters in job.


Build Parameter

Description

testCaseIdThe name of the test case
deviceMacMAC address of the device
executionModeThe execution environment like RDKB or RDKB
repoThe repository which has to be cloned
EXECUTION_IDThe execution id which comes for debugger service
serviceHost

The host name of the debugger service

end_point

Enter the default value as RACK_DEVICE


Add a Choise Parameter
.

Parameter Name

Description

branchThe branch name for the repo to cloned. Give rdk-next as the choice

Configure Source Code Management

 

  • Build Steps

    Under Build steps click on Execute shell option and add below configuration

    #!/bin/bash
    chmod 777 src/main/resources/pre-test-config.sh
    if [[ "$executionMode" =~ .*"RDKV".* ]]; then
        echo "Mode: $executionMode"
        src/main/resources/pre-test-config.sh -g 'group id' -a 'artifact-id' -v 'version'
        src/main/resources/pre-test-config.sh -g 'group id' -a 'artifact-id' -v 'version'
    else
        echo "Mode: $executionMode"
        src/main/resources/pre-test-config.sh -g 'group id' -a 'artifact-id' -v 'version'
        src/main/resources/pre-test-config.sh -g 'group id' -a 'artifact-id' -v 'version'
    fi

    curl -X PUT -4kw \\nstatus_code:%{http_code}\\n -H "Content-Type: application/json" ${serviceHost}/debuggerservice/updateOverAllStatus -d "{"executionId": ${EXECUTION_ID}, "overallStatus": "INPROGRESS"}"


    Before configuring this step in Jenkins, it is required that the Partner Java API project is developed and deployed in Partner's self hosted repository.

    Copy the script file pre-test-config.sh and keep it in Jenkins VM. And configure it as shown below. Here, the script is copied to location /mnt/scripts in Jenkins VM.

    The parameters to the script are 

    -g - Expects the group id of partner java api maven artifact.

    -a - Expects the artifact id of partner java api maven artifact.

    -v - Expects the version of partner java api maven artifact.

    The Jenkins job will clone the test project and then will execute below script. This script will add partner java dependency to test project pom.xml at runtime. After this script is executed, maven goal for test execution will be executed.

    Under Build section, please click on 'Add build step' and select option 'Shell Script'.






    Add another shell command by clicking on the Execute shell option

    curl -X PUT -4kw \\nstatus_code:%{http_code}\\n -H "Content-Type: application/json" ${serviceHost}/debuggerservice/updateJenkinsUrl -d "{'executionId': ${EXECUTION_ID}, 'jenkinsUrl': '${BUILD_URL}console'}"





Configure Maven Goal for Test Execution

    • Under Build section, please click on 'Add build step' and select option 'Invoke top-level Maven targets'. Then, add below maven command in Goals section
Goals 

clean install -U exec:java -DskipTests=true -DretryByDefault=false -DbuildType=RDK -Dhttps.protocols=TLSv1.1,TLSv1.2

-Dsun.security.ssl.allowUnsafeRenegotiation=true -Dautomatics.properties.file={automatics_properties_base_url}/automatics.properties -Dproperties.file.token={Base 64 encrypted login id and password separated by colon }

properties.file.token parameter is used to authenticate automatics properties. The token should be base 64 encrypted with login id and password separated by colon format.
example: admin:automatics when we encrypt it, the value will be YWRtaW46YXV0b21hdGljcw==


    • Click on Advanced option,
      • Add the below JVM Options 
        JDK17 JVM Options
        --add-opens=java.base/java.lang=ALL-UNNAMED
        --add-opens=java.base/java.lang.reflect=ALL-UNNAMED
        --add-opens=java.base/java.util=ALL-UNNAMED
        --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
        --add-opens=java.base/java.io=ALL-UNNAMED
        --add-opens=java.management/javax.management=ALL-UNNAMED
        --add-opens=java.desktop/sun.font=ALL-UNNAMED
        --add-opens=java.base/sun.reflect.generics.parser=ALL-UNNAMED
        --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
        --add-opens=java.base/java.time=ALL-UNNAMED
        --add-opens=java.base/java.time.format=ALL-UNNAMED
        --add-exports=java.base/sun.util.calendar=ALL-UNNAMED
        --add-exports=java.base/sun.security.action=ALL-UNNAMED
        --add-exports=java.xml/jdk.xml.internal=ALL-UNNAMED
        --add-opens
        java.base/java.net=ALL-UNNAMED
        --add-opens
        java.base/java.lang.invoke=ALL-UNNAMED
      • Select option 'Inject Build Variables'.
      • Override maven default settings, if required only. 

Configure Post-Build Actions

 Configure post build actions as shown below.
Under Post build task option, add the below configuration

curl -X PUT -4kw \\nstatus_code:%{http_code}\\n -H "Content-Type: application/json" ${serviceHost}/debuggerservice/updateOverAllStatus -d "{'executionId': ${EXECUTION_ID}, 'overallStatus': 'COMPLETED'}"




Under Archive the artifacts option, add the below configuration

                     


    • Click on Apply and Save button.


Jenkins Job for Scripted Test Case

  • From Jenkins, select option “New Item” and specify name of the job to be created and select “OK”. 
  • Click on newly created Jenkins job and click on Configure option. Job configuration can be edited now.

Configure Build Parameters

In General section

    • Check the “Discard old builds”.
    • Select Log Rotation and we can keep the days of build and Max # of builds.
    • Check the "This project is parameterized".

Please configure following String build parameters in job.


Build Parameter

Description

filterTestIdsThe name of the test case
settopListMAC address of the device
executionModeThe execution environment like RDKB or RDKB
UXGive the default value as RDKM
grThe repo name which will be used for cloning the project
filterTestTypeThe test type for the de
EXECUTION_IDThe execution id which comes for debugger service
serviceHost

The host name of the debugger service

end_point

Enter the default value as RACK_DEVICE


Add a Choise Parameter
.

Parameter Name

Description

grbThe branch name for the repo to cloned. Give rdk-next as the choice

Configure Source Code Management

  • Under Source Code Management, Select option 'GIT'.

       

  • Build Steps

    Under Build steps click on Execute shell option and add below configuration

    #!/bin/bash
    chmod 777 src/main/resources/pre-test-config.sh
    if [[ "$executionMode" =~ .*"RDKV".* ]]; then
        echo "Mode: $executionMode"
        src/main/resources/pre-test-config.sh -g 'group id' -a 'artifact-id' -v 'version'
        src/main/resources/pre-test-config.sh -g 'group id' -a 'artifact-id' -v 'version'
    else
        echo "Mode: $executionMode"
        src/main/resources/pre-test-config.sh -g 'group id' -a 'artifact-id' -v 'version'
        src/main/resources/pre-test-config.sh -g 'group id' -a 'artifact-id' -v 'version'
    fi

    curl -X PUT -4kw \\nstatus_code:%{http_code}\\n -H "Content-Type: application/json" ${serviceHost}/debuggerservice/updateOverAllStatus -d "{"executionId": ${EXECUTION_ID}, "overallStatus": "INPROGRESS"}"

    Before configuring this step in Jenkins, it is required that the Partner Java API project is developed and deployed in Partner's self hosted repository.

    Copy the script file pre-test-config.sh and keep it in Jenkins VM. And configure it as shown below. Here, the script is copied to location /mnt/scripts in Jenkins VM.

    The parameters to the script are 

    -g - Expects the group id of partner java api maven artifact.

    -a - Expects the artifact id of partner java api maven artifact.

    -v - Expects the version of partner java api maven artifact.

    The Jenkins job will clone the test project and then will execute below script. This script will add partner java dependency to test project pom.xml at runtime. After this script is executed, maven goal for test execution will be executed.

    Under Build section, please click on 'Add build step' and select option 'Shell Script'.





    Add another shell command by clicking on the Execute shell option

    curl -X PUT -4kw \\nstatus_code:%{http_code}\\n -H "Content-Type: application/json" ${serviceHost}/debuggerservice/updateJenkinsUrl -d "{'executionId': ${EXECUTION_ID}, 'jenkinsUrl': '${BUILD_URL}console'}"





Configure Maven Goal for Test Execution

    • Under Build section, please click on 'Add build step' and select option 'Invoke top-level Maven targets'. Then, add below maven command in Goals section
Goals 

clean install -U exec:java -DskipTests=true -DretryByDefault=false -DbuildType=RDK -Dhttps.protocols=TLSv1.1,TLSv1.2

-Dsun.security.ssl.allowUnsafeRenegotiation=true -Dautomatics.properties.file={automatics_properties_base_url}/automatics.properties -Dproperties.file.token={Base 64 encrypted login id and password separated by colon }

properties.file.token parameter is used to authenticate automatics properties. The token should be base 64 encrypted with login id and password separated by colon format.
example: admin:automatics when we encrypt it, the value will be YWRtaW46YXV0b21hdGljcw==


    • Click on Advanced option,
      • Add the below JVM Options 
        JDK17 JVM Options
        --add-opens=java.base/java.lang=ALL-UNNAMED
        --add-opens=java.base/java.lang.reflect=ALL-UNNAMED
        --add-opens=java.base/java.util=ALL-UNNAMED
        --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
        --add-opens=java.base/java.io=ALL-UNNAMED
        --add-opens=java.management/javax.management=ALL-UNNAMED
        --add-opens=java.desktop/sun.font=ALL-UNNAMED
        --add-opens=java.base/sun.reflect.generics.parser=ALL-UNNAMED
        --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
        --add-opens=java.base/java.time=ALL-UNNAMED
        --add-opens=java.base/java.time.format=ALL-UNNAMED
        --add-exports=java.base/sun.util.calendar=ALL-UNNAMED
        --add-exports=java.base/sun.security.action=ALL-UNNAMED
        --add-exports=java.xml/jdk.xml.internal=ALL-UNNAMED
        --add-opens
        java.base/java.net=ALL-UNNAMED
        --add-opens
        java.base/java.lang.invoke=ALL-UNNAMED
      • Select option 'Inject Build Variables'.
      • Override maven default settings, if required only. 

Configure Post-Build Actions

 Configure post build actions as shown below.
Under Post build task option, add the below configuration

curl -X PUT -4kw \\nstatus_code:%{http_code}\\n -H "Content-Type: application/json" ${serviceHost}/debuggerservice/updateOverAllStatus -d "{'executionId': ${EXECUTION_ID}, 'overallStatus': 'COMPLETED'}"




Under Archive the artifacts option, add the below configuration

                     


    • Click on Apply and Save button.






  • No labels