Webdriver-IO test framework kullandigimiz bir proje vardi ve burada hem android hemde IOS icn UI testler yapmaktaydik. Bu testler icin iki farkli tipte raport üretebiliyorduk bunlardan biri junit digeri ise “allure”.
Allure un en büyük avantaji grafiksel bir gösterim saglamasi ve hos görünmesi. Dolayisiyla her iki rapor tipindende faydalanmak ve kullanmak istedik. Jenkinste bunu destekliyor. Allure ve Junit pluginlerini kurduk (junit diger pipelinelar nedeniyle zaten mevcuttu).
Allure in problemi iki farkli klasördeki raporlari ayri ayri gösterememesi. Bu nedenle hem pipelinelari ayirmak hemde artifact toplayarak gidebilmek icin bir ana pipeline ve ikide alt pipeline olusturduk.
Mantigi su linkte anlatildigi sekilde kullandik.
https://andrewbayd.medium.com/aggregated-allure-report-using-copy-artifact-jenkins-plugin-843068e216a7
burada sadece bazi pratik noktalardan bahsedecegim.
Önce alt pipeline ayarlari.
- copy artifact e izin.
pipeline {
options {
disableConcurrentBuilds()
copyArtifactPermission('*')
}
2. pipeline sonrasinda artifactleri archive e atnak.
archiveArtifacts artifacts: 'test_framework/report_junit/**/*.*', fingerprint: true, allowEmptyArchive: true
archiveArtifacts artifacts: 'test_framework/allure-results/**/*.*', fingerprint: true, allowEmptyArchive: true
3. package.json da script
"allure": "allure",
"ios": "wdio run ./conf.iossim.ts",
4. conf.ios.ts
baseconfig.reporters = [
'spec',
['allure', {outputDir: 'allure-results'}],
['junit', {
outputDir: 'report_junit',
outputFileFormat: function(options) { // optional
return `results-ios-${options.cid}-${Date.now()}.xml`
}
}]
];
5. jenkinsfile_ios.groovy
npm run ios
Ana pipeline bizim icin önemli kisim.
stage('Test Pipelines') {
parallel {
stage ('IOS') {
steps {
script {
callTests.startIosTesting(FLAVOR, BUILD_NUMBER)
}
}
post {
always {
copyArtifacts (
filter: "test_framework/allure-results/*",
projectName: "<Jenkins path of job>",
selector: [
$class: 'LastCompletedBuildSelector'
]
)
copyArtifacts (
filter: "test_framework/report_junit/*",
projectName: "<Jenkins path of job>",
selector: [
$class: 'LastCompletedBuildSelector'
]
)
}
}
}
stage ('ANDROID') {
steps {
script {
callTests.startAndroidTesting(FLAVOR, BUILD_NUMBER_NEXUS)
}
}
post {
copyArtifacts (
filter: "test_framework/allure-results/*",
projectName: "<Jenkins path of job>",
selector: [
$class: 'LastCompletedBuildSelector'
]
)
copyArtifacts (
filter: "test_framework/report_junit/*",
projectName: "<Jenkins path of job>",
selector: [
$class: 'LastCompletedBuildSelector'
]
)
}
}
}
}
}
}
post {
always {
archiveArtifacts artifacts: 'test_framework/report_junit/**/*.*', fingerprint: true, allowEmptyArchive: true
archiveArtifacts artifacts: 'test_framework/allure-results/**/*.*', fingerprint: true, allowEmptyArchive: true
allure([
includeProperties: false,
jdk: '',
properties: [],
reportBuildPolicy: 'ALWAYS',
results: [[path: 'test_framework/allure-results']]
]
)
junit skipPublishingChecks: true, testResults: 'test_framework/report_junit/*.xml'
}
}
fark ettiyseniz “<Jenkins path of job>” seklinde bir deger var buraya cagiracaginiz pipeline job inin Jenkins pathini yazmaniz gerekir. O path i bulmak icin ise ilgili pipeline in full console output unda asagida ki kismi arayip bulmaniz gereklidir.
Notifying branch build status: RUNNING < path iniz burada > #12: Build started