You've already forked jenkins-lib
forked from jenkins/jenkins-lib
Исправление замечаний к PR в upstream (#17)
This commit is contained in:
@@ -133,8 +133,8 @@ pipeline1C()
|
|||||||
* BDD:
|
* BDD:
|
||||||
* Если в конфигурационном файле проекта не заполнена настройка `bdd` -> `vrunnerSteps`, то автоматически выполняется запуск `vrunner vanessa --settings tools/vrunner.json`.
|
* Если в конфигурационном файле проекта не заполнена настройка `bdd` -> `vrunnerSteps`, то автоматически выполняется запуск `vrunner vanessa --settings tools/vrunner.json`.
|
||||||
* YAXUnit:
|
* YAXUnit:
|
||||||
* Если ваши тесты находятся в расширении YAXUnit, то необходимо указать к путь к этому расширению в формате cfe в `yaxunit` -> `cfe`
|
* Необходимо перечислить расширения в `jobConfiguration.json` -> `yaxunit` -> `extensions`. Путь к расширению можно указать либо в виде ссылки на файл cfe, либо в виде пути к исходникам. Пока что поддерживаются только расширения, выгруженные в формате конфигуратора. При переопределении настроек по умолчанию расширение YAXUnit тоже должно быть в этом списке.
|
||||||
* Если ваши тесты находятся в отдельных расширениях, то необходимо (1) скопировать конфиг из текущей библиотеки (`./resources/yaxunit.json`) в свой репозиторий в `./tools/yaxunit.json` и перечислить в нем имена своих расширений. Имена образуются по правилу: `./src/cfe/unit_tests` -> `unit_tests`. И (2) - перечислить эти же имена в `jobConfiguration.json` -> `yaxunit` -> `extensionNames`. Пока что поддерживаются только расширения, выгруженные в формате конфигуратора.
|
* Если ваши тесты находятся в отдельных расширениях, то необходимо скопировать конфиг из текущей библиотеки (`./resources/yaxunit.json`) в свой репозиторий в `./tools/yaxunit.json` и перечислить в нем имена расширений.
|
||||||
* Дымовые тесты:
|
* Дымовые тесты:
|
||||||
* Если в репозитории существует файл `tools/vrunner.json`, то запуск дымовых тестов будет выполняться с передачей файла в параметры запуска `vrunner xunit --settings tools/vrunner.json` (`smoke` -> `vrunnerSettings`).
|
* Если в репозитории существует файл `tools/vrunner.json`, то запуск дымовых тестов будет выполняться с передачей файла в параметры запуска `vrunner xunit --settings tools/vrunner.json` (`smoke` -> `vrunnerSettings`).
|
||||||
* Если установка локальных зависимостей `opm` установит пакет `add`, то будет использоваться обработка `xddTestRunner.epf` из локальных зависимостей.
|
* Если установка локальных зависимостей `opm` установит пакет `add`, то будет использоваться обработка `xddTestRunner.epf` из локальных зависимостей.
|
||||||
|
@@ -84,8 +84,12 @@
|
|||||||
},
|
},
|
||||||
"yaxunit": {
|
"yaxunit": {
|
||||||
"vrunnerSettings": "./tools/vrunner.json",
|
"vrunnerSettings": "./tools/vrunner.json",
|
||||||
"cfe": "https://github.com/bia-technologies/yaxunit/releases/download/23.05/YAXUNIT-23.05.cfe",
|
"extensions": [
|
||||||
"extensionNames": ["YAXUNIT"],
|
{
|
||||||
|
"name":"YAXUNIT",
|
||||||
|
"src": "https://github.com/bia-technologies/yaxunit/releases/download/23.05/YAXUNIT-23.05.cfe"
|
||||||
|
}
|
||||||
|
],
|
||||||
"configPath": "./tools/yaxunit.json",
|
"configPath": "./tools/yaxunit.json",
|
||||||
"publishToAllureReport": false,
|
"publishToAllureReport": false,
|
||||||
"publishToJUnitReport": true
|
"publishToJUnitReport": true
|
||||||
|
@@ -69,7 +69,7 @@
|
|||||||
},
|
},
|
||||||
"yaxunit": {
|
"yaxunit": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Юнит тесты"
|
"description" : "Запуск YAXUnit тестов включен"
|
||||||
},
|
},
|
||||||
"initSteps": {
|
"initSteps": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
},
|
},
|
||||||
"yaxunit": {
|
"yaxunit": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "Таймаут шага Юнит тестов, в минутах.\n По умолчанию содержит значение 240.\n "
|
"description" : "Таймаут шага YAXUnit тестов, в минутах.\n По умолчанию содержит значение 240.\n "
|
||||||
},
|
},
|
||||||
"sonarqube": {
|
"sonarqube": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
@@ -301,7 +301,7 @@
|
|||||||
"yaxunit": {
|
"yaxunit": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"id": "urn:jsonschema:ru:pulsar:jenkins:library:configuration:YaxunitOptions",
|
"id": "urn:jsonschema:ru:pulsar:jenkins:library:configuration:YaxunitOptions",
|
||||||
"description": "Настройки юнит тестирования",
|
"description" : "Настройки YAXUnit",
|
||||||
"properties": {
|
"properties": {
|
||||||
"vrunnerSettings": {
|
"vrunnerSettings": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@@ -26,6 +26,8 @@ interface IStepExecutor {
|
|||||||
|
|
||||||
String readFile(String file, String encoding)
|
String readFile(String file, String encoding)
|
||||||
|
|
||||||
|
void writeFile(String file, String text, String encoding)
|
||||||
|
|
||||||
boolean fileExists(String file)
|
boolean fileExists(String file)
|
||||||
|
|
||||||
void echo(message)
|
void echo(message)
|
||||||
|
@@ -42,6 +42,11 @@ class StepExecutor implements IStepExecutor {
|
|||||||
steps.readFile encoding: encoding, file: file
|
steps.readFile encoding: encoding, file: file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void writeFile(String file, String text, String encoding = 'UTF-8') {
|
||||||
|
steps.writeFile encoding: encoding, file: file, text: text
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean fileExists(String file) {
|
boolean fileExists(String file) {
|
||||||
steps.fileExists file
|
steps.fileExists file
|
||||||
|
@@ -66,6 +66,7 @@ class ConfigurationReader implements Serializable {
|
|||||||
"sonarQubeOptions",
|
"sonarQubeOptions",
|
||||||
"smokeTestOptions",
|
"smokeTestOptions",
|
||||||
"yaxunitOptions",
|
"yaxunitOptions",
|
||||||
|
"extensions",
|
||||||
"syntaxCheckOptions",
|
"syntaxCheckOptions",
|
||||||
"resultsTransformOptions",
|
"resultsTransformOptions",
|
||||||
"notificationsOptions",
|
"notificationsOptions",
|
||||||
@@ -150,10 +151,10 @@ class ConfigurationReader implements Serializable {
|
|||||||
|
|
||||||
@NonCPS
|
@NonCPS
|
||||||
private static void mergeYaxunitOptions(YaxunitOptions baseObject, YaxunitOptions objectToMerge) {
|
private static void mergeYaxunitOptions(YaxunitOptions baseObject, YaxunitOptions objectToMerge) {
|
||||||
if (objectToMerge == null || objectToMerge.extensionNames == null) {
|
if (objectToMerge == null || objectToMerge.extensions == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
baseObject.extensionNames = objectToMerge.extensionNames.clone()
|
baseObject.extensions = objectToMerge.extensions.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonCPS
|
@NonCPS
|
||||||
|
17
src/ru/pulsar/jenkins/library/configuration/Extension.groovy
Normal file
17
src/ru/pulsar/jenkins/library/configuration/Extension.groovy
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package ru.pulsar.jenkins.library.configuration
|
||||||
|
|
||||||
|
import com.cloudbees.groovy.cps.NonCPS
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
class Extension implements Serializable {
|
||||||
|
String name
|
||||||
|
String src
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonCPS
|
||||||
|
String toString() {
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -56,7 +56,7 @@ class JobConfiguration implements Serializable {
|
|||||||
SmokeTestOptions smokeTestOptions;
|
SmokeTestOptions smokeTestOptions;
|
||||||
|
|
||||||
@JsonProperty("yaxunit")
|
@JsonProperty("yaxunit")
|
||||||
@JsonPropertyDescription("Настройки юнит тестирования")
|
@JsonPropertyDescription("Настройки YAXUnit")
|
||||||
YaxunitOptions yaxunitOptions;
|
YaxunitOptions yaxunitOptions;
|
||||||
|
|
||||||
@JsonProperty("resultsTransform")
|
@JsonProperty("resultsTransform")
|
||||||
|
@@ -18,7 +18,7 @@ class StageFlags implements Serializable {
|
|||||||
@JsonPropertyDescription("Дымовые тесты включены")
|
@JsonPropertyDescription("Дымовые тесты включены")
|
||||||
Boolean smoke
|
Boolean smoke
|
||||||
|
|
||||||
@JsonPropertyDescription("Юнит тесты")
|
@JsonPropertyDescription("Запуск YAXUnit тестов включен")
|
||||||
Boolean yaxunit
|
Boolean yaxunit
|
||||||
|
|
||||||
@JsonPropertyDescription("Предварительные шаги инициализации включены")
|
@JsonPropertyDescription("Предварительные шаги инициализации включены")
|
||||||
|
@@ -66,7 +66,7 @@ class TimeoutOptions implements Serializable {
|
|||||||
''')
|
''')
|
||||||
Integer smoke
|
Integer smoke
|
||||||
|
|
||||||
@JsonPropertyDescription('''Таймаут шага Юнит тестов, в минутах.
|
@JsonPropertyDescription('''Таймаут шага YAXUnit тестов, в минутах.
|
||||||
По умолчанию содержит значение 240.
|
По умолчанию содержит значение 240.
|
||||||
''')
|
''')
|
||||||
Integer yaxunit
|
Integer yaxunit
|
||||||
|
@@ -2,6 +2,7 @@ package ru.pulsar.jenkins.library.configuration
|
|||||||
|
|
||||||
import com.cloudbees.groovy.cps.NonCPS
|
import com.cloudbees.groovy.cps.NonCPS
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription
|
import com.fasterxml.jackson.annotation.JsonPropertyDescription
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
@@ -12,15 +13,14 @@ class YaxunitOptions implements Serializable {
|
|||||||
""")
|
""")
|
||||||
String vrunnerSettings = "./tools/vrunner.json"
|
String vrunnerSettings = "./tools/vrunner.json"
|
||||||
|
|
||||||
@JsonPropertyDescription("""Ссылка на скачивание YAXUnit.
|
@JsonProperty("extensions")
|
||||||
По умолчанию содержит ссылку на официальный релиз версии 23.05.
|
@JsonPropertyDescription("""Расширения с тестами.
|
||||||
|
Массив объектов с полями name и src, где
|
||||||
|
name - имя расширения
|
||||||
|
src - путь к расширению (к cfe или к исходникам)
|
||||||
|
По умолчанию содержит один элемент - YAXUNIT версии 23.05.
|
||||||
""")
|
""")
|
||||||
String cfe = "https://github.com/bia-technologies/yaxunit/releases/download/23.05/YAXUNIT-23.05.cfe"
|
Extension[] extensions
|
||||||
|
|
||||||
@JsonPropertyDescription("""Имена расширений с тестами.
|
|
||||||
По умолчанию содержит один элемент - YAXUNIT.
|
|
||||||
""")
|
|
||||||
String[] extensionNames = ['YAXUNIT']
|
|
||||||
|
|
||||||
@JsonPropertyDescription("""Путь к конфигурационному файлу YAXUnit.
|
@JsonPropertyDescription("""Путь к конфигурационному файлу YAXUnit.
|
||||||
По умолчанию содержит значение "./tools/yaxunit.json".
|
По умолчанию содержит значение "./tools/yaxunit.json".
|
||||||
@@ -42,8 +42,7 @@ class YaxunitOptions implements Serializable {
|
|||||||
String toString() {
|
String toString() {
|
||||||
return "YaxunitTestOptions{" +
|
return "YaxunitTestOptions{" +
|
||||||
"vrunnerSettings='" + vrunnerSettings + '\'' +
|
"vrunnerSettings='" + vrunnerSettings + '\'' +
|
||||||
", cfe='" + cfe +
|
", extensions='" + extensions +
|
||||||
", extensionNames='" + extensionNames.toString() +
|
|
||||||
", configPath='" + configPath +
|
", configPath='" + configPath +
|
||||||
'}'
|
'}'
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@ package ru.pulsar.jenkins.library.steps
|
|||||||
|
|
||||||
import hudson.FilePath
|
import hudson.FilePath
|
||||||
import ru.pulsar.jenkins.library.IStepExecutor
|
import ru.pulsar.jenkins.library.IStepExecutor
|
||||||
|
import ru.pulsar.jenkins.library.configuration.Extension
|
||||||
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||||
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||||
import ru.pulsar.jenkins.library.utils.FileUtils
|
import ru.pulsar.jenkins.library.utils.FileUtils
|
||||||
@@ -12,8 +13,6 @@ class Yaxunit implements Serializable {
|
|||||||
|
|
||||||
private final JobConfiguration config
|
private final JobConfiguration config
|
||||||
|
|
||||||
private final String yaxunitPath = 'build/out/yaxunit.cfe'
|
|
||||||
|
|
||||||
private final String DEFAULT_YAXUNIT_CONFIGURATION_RESOURCE = 'yaxunit.json'
|
private final String DEFAULT_YAXUNIT_CONFIGURATION_RESOURCE = 'yaxunit.json'
|
||||||
|
|
||||||
public static final String YAXUNIT_ALLURE_STASH = 'yaxunit-allure'
|
public static final String YAXUNIT_ALLURE_STASH = 'yaxunit-allure'
|
||||||
@@ -43,32 +42,29 @@ class Yaxunit implements Serializable {
|
|||||||
String vrunnerPath = VRunner.getVRunnerPath()
|
String vrunnerPath = VRunner.getVRunnerPath()
|
||||||
String ibConnection = ' --ibconnection "/F./build/ib"'
|
String ibConnection = ' --ibconnection "/F./build/ib"'
|
||||||
|
|
||||||
// Скачиваем YAXUnit
|
|
||||||
String pathToYaxunit = "$env.WORKSPACE/$yaxunitPath"
|
|
||||||
FilePath localPathToYaxunit = FileUtils.getFilePath(pathToYaxunit)
|
|
||||||
Logger.println("Скачивание YAXUnit в $localPathToYaxunit из ${options.cfe}")
|
|
||||||
localPathToYaxunit.copyFrom(new URL(options.cfe))
|
|
||||||
|
|
||||||
def extCommands = []
|
def extCommands = []
|
||||||
|
|
||||||
// Команда загрузки YAXUnit
|
// Команда загрузки YAXUnit
|
||||||
def loadYaxunitCommand = VRunner.loadExtCommand("yaxunit")
|
def loadYaxunitCommand = VRunner.loadExtCommand("yaxunit")
|
||||||
extCommands << loadYaxunitCommand
|
extCommands << loadYaxunitCommand
|
||||||
|
|
||||||
|
|
||||||
// Команды сборки расширений с тестами и их загрузки в ИБ
|
// Команды сборки расширений с тестами и их загрузки в ИБ
|
||||||
for (String extension in options.extensionNames) {
|
for (Extension extension in options.extensions) {
|
||||||
if (extension.toUpperCase() == "YAXUNIT") {
|
if (extension.src.endsWith('cfe')) {
|
||||||
continue
|
// Скачиваем расширение
|
||||||
|
String pathToExtension = "$env.WORKSPACE/build/out/${extension.name}.cfe"
|
||||||
|
FilePath localPathToExtension = FileUtils.getFilePath(pathToExtension)
|
||||||
|
Logger.println("Скачивание расширения $extension.name в $localPathToExtension из ${extension.src}")
|
||||||
|
localPathToExtension.copyFrom(new URL(extension.src))
|
||||||
|
} else {
|
||||||
|
// Команда компиляции в cfe
|
||||||
|
def compileExtCommand = "$vrunnerPath compileexttocfe --src $extension.src --out build/out/${extension.name}.cfe"
|
||||||
|
extCommands << compileExtCommand
|
||||||
|
Logger.println("Команда сборки расширения: $compileExtCommand")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Команда компиляции в cfe
|
|
||||||
def compileExtCommand = "$vrunnerPath compileexttocfe --src ./src/cfe/$extension --out build/out/${extension}.cfe"
|
|
||||||
extCommands << compileExtCommand
|
|
||||||
Logger.println("Команда сборки расширения: $compileExtCommand")
|
|
||||||
|
|
||||||
// Команда загрузки расширения в ИБ
|
// Команда загрузки расширения в ИБ
|
||||||
def loadTestExtCommand = VRunner.loadExtCommand(extension)
|
def loadTestExtCommand = VRunner.loadExtCommand(extension.name)
|
||||||
extCommands << loadTestExtCommand
|
extCommands << loadTestExtCommand
|
||||||
Logger.println("Команда загрузки расширения: $loadTestExtCommand")
|
Logger.println("Команда загрузки расширения: $loadTestExtCommand")
|
||||||
|
|
||||||
@@ -76,12 +72,11 @@ class Yaxunit implements Serializable {
|
|||||||
|
|
||||||
// Готовим конфиг для yaxunit
|
// Готовим конфиг для yaxunit
|
||||||
String yaxunitConfigPath = options.configPath
|
String yaxunitConfigPath = options.configPath
|
||||||
File yaxunitConfigFile = new File("$env.WORKSPACE/$yaxunitConfigPath")
|
|
||||||
if (!steps.fileExists(yaxunitConfigPath)) {
|
if (!steps.fileExists(yaxunitConfigPath)) {
|
||||||
def defaultYaxunitConfig = steps.libraryResource DEFAULT_YAXUNIT_CONFIGURATION_RESOURCE
|
def defaultYaxunitConfig = steps.libraryResource DEFAULT_YAXUNIT_CONFIGURATION_RESOURCE
|
||||||
yaxunitConfigFile.write defaultYaxunitConfig
|
steps.writeFile(options.configPath, defaultYaxunitConfig, 'UTF-8')
|
||||||
}
|
}
|
||||||
def yaxunitConfig = yaxunitConfigFile.getCanonicalPath()
|
def yaxunitConfig = FileUtils.getFilePath(yaxunitConfigPath)
|
||||||
|
|
||||||
// Команда запуска тестов
|
// Команда запуска тестов
|
||||||
String runTestsCommand = "$vrunnerPath run --command RunUnitTests=$yaxunitConfig $ibConnection"
|
String runTestsCommand = "$vrunnerPath run --command RunUnitTests=$yaxunitConfig $ibConnection"
|
||||||
|
@@ -74,5 +74,6 @@ class jobConfigurationTest {
|
|||||||
rule.assertLogContains("v8version='8.3.12.1500'", run)
|
rule.assertLogContains("v8version='8.3.12.1500'", run)
|
||||||
rule.assertLogContains("sonarScannerToolName='sonar-scanner'", run)
|
rule.assertLogContains("sonarScannerToolName='sonar-scanner'", run)
|
||||||
rule.assertLogContains("initMethod=FROM_SOURCE", run)
|
rule.assertLogContains("initMethod=FROM_SOURCE", run)
|
||||||
|
rule.assertLogContains("custom_units", run)
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -7,5 +7,7 @@
|
|||||||
"initMethod": "fromSource",
|
"initMethod": "fromSource",
|
||||||
"path": "/src/cfe/тест"
|
"path": "/src/cfe/тест"
|
||||||
}]
|
}]
|
||||||
|
},
|
||||||
|
"yaxunit": {
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -244,7 +244,7 @@ void call() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Юнит тесты') {
|
stage('YAXUnit тесты') {
|
||||||
agent {
|
agent {
|
||||||
label agent1C
|
label agent1C
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user