mirror of
https://github.com/firstBitMarksistskaya/jenkins-lib.git
synced 2025-02-14 15:00:06 +02:00
Сохранение allure
This commit is contained in:
parent
58ae0ac197
commit
6893b6610e
@ -48,9 +48,9 @@ interface IStepExecutor {
|
|||||||
|
|
||||||
def catchError(Closure body)
|
def catchError(Closure body)
|
||||||
|
|
||||||
def httpRequest(String url, String outputFile)
|
|
||||||
|
|
||||||
def httpRequest(String url, String outputFile, String responseHandle, boolean wrapAsMultipart)
|
def httpRequest(String url, String outputFile, String responseHandle, boolean wrapAsMultipart)
|
||||||
|
|
||||||
def error(String errorMessage)
|
def error(String errorMessage)
|
||||||
|
|
||||||
|
def allure(List<String> results)
|
||||||
}
|
}
|
@ -113,4 +113,16 @@ class StepExecutor implements IStepExecutor {
|
|||||||
def error(String errorMessage) {
|
def error(String errorMessage) {
|
||||||
steps.error errorMessage
|
steps.error errorMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
def allure(List<String> results) {
|
||||||
|
steps.allure([
|
||||||
|
commandline: 'allure',
|
||||||
|
includeProperties: false,
|
||||||
|
jdk: '',
|
||||||
|
properties: [],
|
||||||
|
reportBuildPolicy: 'ALWAYS',
|
||||||
|
results: results
|
||||||
|
])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,9 @@ class InitInfobase implements Serializable {
|
|||||||
Logger.println("Запуск миграции ИБ")
|
Logger.println("Запуск миграции ИБ")
|
||||||
|
|
||||||
// Запуск миграции
|
// Запуск миграции
|
||||||
steps.cmd('oscript_modules/bin/vrunner run --command "ЗапуститьОбновлениеИнформационнойБазы;ЗавершитьРаботуСистемы;" --execute \\$runnerRoot/epf/ЗакрытьПредприятие.epf --ibconnection "/F./build/ib"')
|
steps.catchError {
|
||||||
|
steps.cmd('oscript_modules/bin/vrunner run --command "ЗапуститьОбновлениеИнформационнойБазы;ЗавершитьРаботуСистемы;" --execute \\$runnerRoot/epf/ЗакрытьПредприятие.epf --ibconnection "/F./build/ib"')
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger.println("Шаг миграции ИБ выключен")
|
Logger.println("Шаг миграции ИБ выключен")
|
||||||
}
|
}
|
||||||
@ -40,9 +42,11 @@ class InitInfobase implements Serializable {
|
|||||||
'oscript_modules/vanessa-automation-single/vanessa-automation-single.epf'
|
'oscript_modules/vanessa-automation-single/vanessa-automation-single.epf'
|
||||||
)
|
)
|
||||||
|
|
||||||
config.initInfobaseOptions.additionalMigrationSteps.each {
|
steps.catchError {
|
||||||
Logger.println("Первичная инициализация командой ${it}")
|
config.initInfobaseOptions.additionalMigrationSteps.each {
|
||||||
steps.cmd("oscript_modules/bin/vrunner ${it} --ibconnection \"/F./build/ib\"")
|
Logger.println("Первичная инициализация командой ${it}")
|
||||||
|
steps.cmd("oscript_modules/bin/vrunner ${it} --ibconnection \"/F./build/ib\"")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
steps.stash('init-allure', 'build/out/allure/*', true)
|
steps.stash('init-allure', 'build/out/allure/*', true)
|
||||||
|
45
src/ru/pulsar/jenkins/library/steps/PublishAllure.groovy
Normal file
45
src/ru/pulsar/jenkins/library/steps/PublishAllure.groovy
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package ru.pulsar.jenkins.library.steps
|
||||||
|
|
||||||
|
import hudson.FilePath
|
||||||
|
import ru.pulsar.jenkins.library.IStepExecutor
|
||||||
|
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||||
|
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||||
|
import ru.pulsar.jenkins.library.utils.FileUtils
|
||||||
|
import ru.pulsar.jenkins.library.utils.Logger
|
||||||
|
|
||||||
|
class PublishAllure implements Serializable {
|
||||||
|
|
||||||
|
private final JobConfiguration config;
|
||||||
|
|
||||||
|
PublishAllure(JobConfiguration config) {
|
||||||
|
this.config = config
|
||||||
|
}
|
||||||
|
|
||||||
|
def run() {
|
||||||
|
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||||
|
|
||||||
|
Logger.printLocation()
|
||||||
|
|
||||||
|
steps.unstash('init-allure')
|
||||||
|
|
||||||
|
FilePath allurePath = FileUtils.getFilePath('build/out/allure')
|
||||||
|
if (!allurePath.exists()) {
|
||||||
|
Logger.println("Отсутствуют результаты allure для публикации")
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> results = new ArrayList<>();
|
||||||
|
|
||||||
|
def allureSubDirs = allurePath.listDirectories()
|
||||||
|
if (allureSubDirs.size() > 0) {
|
||||||
|
allureSubDirs.forEach({ filePath -> results.add(getPath(filePath)) })
|
||||||
|
} else {
|
||||||
|
results.add(getPath(allurePath))
|
||||||
|
}
|
||||||
|
|
||||||
|
steps.allure(results)
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getPath(FilePath filePath) {
|
||||||
|
filePath.getBaseName() + File.separator + filePath.getName()
|
||||||
|
}
|
||||||
|
}
|
27
src/ru/pulsar/jenkins/library/utils/FileUtils.groovy
Normal file
27
src/ru/pulsar/jenkins/library/utils/FileUtils.groovy
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package ru.pulsar.jenkins.library.utils
|
||||||
|
|
||||||
|
import hudson.FilePath
|
||||||
|
import jenkins.model.Jenkins
|
||||||
|
import ru.pulsar.jenkins.library.IStepExecutor
|
||||||
|
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||||
|
|
||||||
|
class FileUtils {
|
||||||
|
|
||||||
|
static FilePath getFilePath(String path) {
|
||||||
|
|
||||||
|
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||||
|
|
||||||
|
def env = steps.env();
|
||||||
|
|
||||||
|
String nodeName = env.NODE_NAME;
|
||||||
|
if (nodeName == null) {
|
||||||
|
steps.error 'Переменная среды NODE_NAME не задана. Запуск вне node или без agent?'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nodeName == "master") {
|
||||||
|
return new FilePath(new File(path));
|
||||||
|
} else {
|
||||||
|
return new FilePath(Jenkins.getInstanceOrNull().getComputer(nodeName).getChannel(), path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -66,8 +66,6 @@ void call() {
|
|||||||
expression { config.stageFlags.initSteps }
|
expression { config.stageFlags.initSteps }
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
printLocation()
|
|
||||||
|
|
||||||
// Инициализация и первичная миграция
|
// Инициализация и первичная миграция
|
||||||
initInfobase config
|
initInfobase config
|
||||||
}
|
}
|
||||||
@ -169,6 +167,14 @@ void call() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
post('post-stage') {
|
||||||
|
always {
|
||||||
|
node('agent') {
|
||||||
|
saveResults config
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
32
vars/saveResults.groovy
Normal file
32
vars/saveResults.groovy
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||||
|
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||||
|
import ru.pulsar.jenkins.library.steps.PublishAllure
|
||||||
|
|
||||||
|
def call(JobConfiguration config) {
|
||||||
|
ContextRegistry.registerDefaultContext(this)
|
||||||
|
|
||||||
|
def publishAllure = new PublishAllure(config)
|
||||||
|
publishAllure.run()
|
||||||
|
|
||||||
|
// step([
|
||||||
|
// $class: 'CucumberReportPublisher',
|
||||||
|
// fileIncludePattern: '*.json',
|
||||||
|
// jsonReportDirectory: 'build/out/cucumber'
|
||||||
|
// ])
|
||||||
|
//
|
||||||
|
// step([
|
||||||
|
// $class: 'CukedoctorPublisher',
|
||||||
|
// featuresDir: 'build/out/cucumber',
|
||||||
|
// format: 'HTML',
|
||||||
|
// hideFeaturesSection: false,
|
||||||
|
// hideScenarioKeyword: false,
|
||||||
|
// hideStepTime: false,
|
||||||
|
// hideSummary: false,
|
||||||
|
// hideTags: false,
|
||||||
|
// numbered: true,
|
||||||
|
// sectAnchors: true,
|
||||||
|
// title: 'Living Documentation',
|
||||||
|
// toc: 'LEFT'
|
||||||
|
// ])
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user