Powered By Blogger

Search Here!

Showing posts with label Build Parameters. Show all posts
Showing posts with label Build Parameters. Show all posts

Tuesday, June 15, 2021

Setup Automated Mobile Test Build Parameters in Jenkins !

Jenkins File -

properties([ 
disableConcurrentBuilds(),
buildDiscarder(logRotator(numToKeepStr: '25')),
parameters([
string(defaultValue: "localhost", description: 'Server Login IP address', name: 'LOGIN-IP-VALUE'),
choice(choices: ['All','Smoke','Regression'], description: 'Test Suite Name', name: 'Test_Suite_Name'),
choice(choices: ['emulator','device'], description: 'Device Type', name: 'DEVICE_TYPE'),
extendedChoice(name: 'Slave', value: 'Manish,Evan,Max', defaultValue: 'Manish', description: 'Slave Machine Name', type: 'PT_MULTI_SELECT', visibleItemCount: 2)
])
])

node("${env.Slave}") {
stage('Checkout') {
timestamps {
checkout scm
}
}

stage('Test') {
timestamps {
try {
bat 'python.exe -m robot --variable LOGIN-IP-VALUE:%LOGIN-IP-VALUE% --variable DEVICE_TYPE:%DEVICE_TYPE% -d Output -i %Test_Suite_Name% --loglevel TRACE Tests/'
} catch (Exception e) {
emailSubject = "Jenkins build Failure: ${JOB_NAME} #${BUILD_NUMBER}"
emailRecipients = [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']]
emailBody = """
<style>
table {border:1px solid #ccc}
th {border:1px solid #ccc}
td {border:1px solid #ccc}
</style>
<table>
<tr><th>Result</th><td>${e}</td></tr>
<tr><th>Name</th><td>${currentBuild.fullDisplayName}</td></tr>
<tr><th>Job URL</th><td><a href="${JOB_URL}">${JOB_URL}</a></td></tr>
<tr><th>Build URL</th><td><a href="${BUILD_URL}">${BUILD_URL}</a></td></tr>
</table>
""".stripIndent()
emailext attachLog: true, mimeType: 'text/html', subject: emailSubject, body: emailBody, recipientProviders: emailRecipients
throw e
} finally {
stage('Generate report') {
publishHTML([allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir:'Output',
reportFiles:'report.html',
reportName:'Mobile Integration Test Report'
])
}
                        }
                }
        }
}

Preview in Jenkins -

As per my assumption out tests should be enough capable to run on the given environment -

LOGIN-IP-VALUE - Execute test's on given IP address.
Test_Suite_Name - Execute tests based on selected types of scenarios.
DEVICE_TYPE - Using emulator or on the real device connected via USB.
Slave - Execute test on different machines based on user identity.