You've already forked jenkins-lib
forked from jenkins/jenkins-lib
Рефакторинг
This commit is contained in:
@@ -57,7 +57,7 @@ class ConfigurationReader implements Serializable {
|
|||||||
"secrets",
|
"secrets",
|
||||||
"stageFlags",
|
"stageFlags",
|
||||||
"timeoutOptions",
|
"timeoutOptions",
|
||||||
"initInfobaseOptions",
|
"initInfoBaseOptions",
|
||||||
"bddOptions",
|
"bddOptions",
|
||||||
"sonarQubeOptions",
|
"sonarQubeOptions",
|
||||||
"smokeTestOptions",
|
"smokeTestOptions",
|
||||||
@@ -66,7 +66,7 @@ class ConfigurationReader implements Serializable {
|
|||||||
).toSet()
|
).toSet()
|
||||||
|
|
||||||
mergeObjects(baseConfiguration, configurationToMerge, nonMergeableSettings)
|
mergeObjects(baseConfiguration, configurationToMerge, nonMergeableSettings)
|
||||||
mergeInitInfobaseOptions(baseConfiguration.initInfobaseOptions, configurationToMerge.initInfobaseOptions);
|
mergeInitInfoBaseOptions(baseConfiguration.initInfoBaseOptions, configurationToMerge.initInfoBaseOptions);
|
||||||
mergeBddOptions(baseConfiguration.bddOptions, configurationToMerge.bddOptions);
|
mergeBddOptions(baseConfiguration.bddOptions, configurationToMerge.bddOptions);
|
||||||
|
|
||||||
return baseConfiguration;
|
return baseConfiguration;
|
||||||
@@ -93,7 +93,7 @@ class ConfigurationReader implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NonCPS
|
@NonCPS
|
||||||
private static void mergeInitInfobaseOptions(InitInfobaseOptions baseObject, InitInfobaseOptions objectToMerge) {
|
private static void mergeInitInfoBaseOptions(InitInfoBaseOptions baseObject, InitInfoBaseOptions objectToMerge) {
|
||||||
if (objectToMerge == null || objectToMerge.additionalInitializationSteps == null) {
|
if (objectToMerge == null || objectToMerge.additionalInitializationSteps == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@ package ru.pulsar.jenkins.library.configuration
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
|
|
||||||
enum InitInfobaseMethod {
|
enum InitInfoBaseMethod {
|
||||||
|
|
||||||
@JsonProperty("fromStorage")
|
@JsonProperty("fromStorage")
|
||||||
FROM_STORAGE,
|
FROM_STORAGE,
|
@@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
|||||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription
|
import com.fasterxml.jackson.annotation.JsonPropertyDescription
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
class InitInfobaseOptions implements Serializable {
|
class InitInfoBaseOptions implements Serializable {
|
||||||
|
|
||||||
@JsonPropertyDescription("""
|
@JsonPropertyDescription("""
|
||||||
Способ инициализации информационной базы.
|
Способ инициализации информационной базы.
|
||||||
@@ -14,7 +14,7 @@ class InitInfobaseOptions implements Serializable {
|
|||||||
* fromSource - инициализация информационной базы из исходников конфигурации;
|
* fromSource - инициализация информационной базы из исходников конфигурации;
|
||||||
* defaultBranchFromStorage - инициализация основной ветки из хранилища конфигурации, остальных - из исходников конфигурации.
|
* defaultBranchFromStorage - инициализация основной ветки из хранилища конфигурации, остальных - из исходников конфигурации.
|
||||||
По умолчанию содержит значение "fromStorage".""")
|
По умолчанию содержит значение "fromStorage".""")
|
||||||
InitInfobaseMethod initMethod = InitInfobaseMethod.FROM_STORAGE;
|
InitInfoBaseMethod initMethod = InitInfoBaseMethod.FROM_STORAGE;
|
||||||
|
|
||||||
@JsonPropertyDescription("Запустить миграцию ИБ")
|
@JsonPropertyDescription("Запустить миграцию ИБ")
|
||||||
boolean runMigration = true
|
boolean runMigration = true
|
||||||
@@ -28,7 +28,7 @@ class InitInfobaseOptions implements Serializable {
|
|||||||
@Override
|
@Override
|
||||||
@NonCPS
|
@NonCPS
|
||||||
String toString() {
|
String toString() {
|
||||||
return "InitInfobaseOptions{" +
|
return "InitInfoBaseOptions{" +
|
||||||
"initMethod=" + initMethod +
|
"initMethod=" + initMethod +
|
||||||
", runMigration=" + runMigration +
|
", runMigration=" + runMigration +
|
||||||
", additionalInitializationSteps=" + additionalInitializationSteps +
|
", additionalInitializationSteps=" + additionalInitializationSteps +
|
@@ -34,7 +34,7 @@ class JobConfiguration implements Serializable {
|
|||||||
|
|
||||||
@JsonProperty("initInfobase")
|
@JsonProperty("initInfobase")
|
||||||
@JsonPropertyDescription("Настройки шага инициализации ИБ")
|
@JsonPropertyDescription("Настройки шага инициализации ИБ")
|
||||||
InitInfobaseOptions initInfobaseOptions;
|
InitInfoBaseOptions initInfoBaseOptions;
|
||||||
|
|
||||||
@JsonProperty("bdd")
|
@JsonProperty("bdd")
|
||||||
@JsonPropertyDescription("Настройки шага запуска BDD сценариев")
|
@JsonPropertyDescription("Настройки шага запуска BDD сценариев")
|
||||||
@@ -71,7 +71,7 @@ class JobConfiguration implements Serializable {
|
|||||||
", timeoutOptions=" + timeoutOptions +
|
", timeoutOptions=" + timeoutOptions +
|
||||||
", defaultBranch='" + defaultBranch + '\'' +
|
", defaultBranch='" + defaultBranch + '\'' +
|
||||||
", secrets=" + secrets +
|
", secrets=" + secrets +
|
||||||
", initInfobaseOptions=" + initInfobaseOptions +
|
", initInfoBaseOptions=" + initInfoBaseOptions +
|
||||||
", bddOptions=" + bddOptions +
|
", bddOptions=" + bddOptions +
|
||||||
", sonarQubeOptions=" + sonarQubeOptions +
|
", sonarQubeOptions=" + sonarQubeOptions +
|
||||||
", syntaxCheckOptions=" + syntaxCheckOptions +
|
", syntaxCheckOptions=" + syntaxCheckOptions +
|
||||||
@@ -81,13 +81,13 @@ class JobConfiguration implements Serializable {
|
|||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean infobaseFromFiles() {
|
boolean infoBaseFromFiles() {
|
||||||
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||||
def env = steps.env();
|
def env = steps.env();
|
||||||
String branchName = env.BRANCH_NAME;
|
String branchName = env.BRANCH_NAME;
|
||||||
def initMethod = initInfobaseOptions.initMethod
|
def initMethod = initInfoBaseOptions.initMethod
|
||||||
|
|
||||||
return (initMethod == InitInfobaseMethod.FROM_SOURCE) ||
|
return (initMethod == InitInfoBaseMethod.FROM_SOURCE) ||
|
||||||
(initMethod == InitInfobaseMethod.DEFAULT_BRANCH_FROM_STORAGE && branchName != defaultBranch)
|
(initMethod == InitInfoBaseMethod.DEFAULT_BRANCH_FROM_STORAGE && branchName != defaultBranch)
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -37,7 +37,7 @@ class StageFlags implements Serializable {
|
|||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean needInfobase() {
|
boolean needInfoBase() {
|
||||||
return smoke || syntaxCheck || initSteps || bdd
|
return smoke || syntaxCheck || initSteps || bdd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@ class InitFromFiles implements Serializable {
|
|||||||
|
|
||||||
Logger.printLocation()
|
Logger.printLocation()
|
||||||
|
|
||||||
if (!config.infobaseFromFiles()) {
|
if (!config.infoBaseFromFiles()) {
|
||||||
Logger.println("init infoBase from files is disabled")
|
Logger.println("init infoBase from files is disabled")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,7 @@ class InitFromStorage implements Serializable {
|
|||||||
|
|
||||||
Logger.printLocation()
|
Logger.printLocation()
|
||||||
|
|
||||||
if (config.infobaseFromFiles()) {
|
if (config.infoBaseFromFiles()) {
|
||||||
Logger.println("init infoBase from storage is disabled")
|
Logger.println("init infoBase from storage is disabled")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -7,11 +7,11 @@ import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
|||||||
import ru.pulsar.jenkins.library.utils.Logger
|
import ru.pulsar.jenkins.library.utils.Logger
|
||||||
import ru.pulsar.jenkins.library.utils.VRunner
|
import ru.pulsar.jenkins.library.utils.VRunner
|
||||||
|
|
||||||
class InitInfobase implements Serializable {
|
class InitInfoBase implements Serializable {
|
||||||
|
|
||||||
private final JobConfiguration config;
|
private final JobConfiguration config;
|
||||||
|
|
||||||
InitInfobase(JobConfiguration config) {
|
InitInfoBase(JobConfiguration config) {
|
||||||
this.config = config
|
this.config = config
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ class InitInfobase implements Serializable {
|
|||||||
|
|
||||||
String vrunnerPath = VRunner.getVRunnerPath();
|
String vrunnerPath = VRunner.getVRunnerPath();
|
||||||
|
|
||||||
if (config.initInfobaseOptions.runMigration) {
|
if (config.initInfoBaseOptions.runMigration) {
|
||||||
Logger.println("Запуск миграции ИБ")
|
Logger.println("Запуск миграции ИБ")
|
||||||
|
|
||||||
String command = vrunnerPath + ' run --command "ЗапуститьОбновлениеИнформационнойБазы;ЗавершитьРаботуСистемы;" --execute '
|
String command = vrunnerPath + ' run --command "ЗапуститьОбновлениеИнформационнойБазы;ЗавершитьРаботуСистемы;" --execute '
|
||||||
@@ -52,7 +52,7 @@ class InitInfobase implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
steps.catchError {
|
steps.catchError {
|
||||||
if (config.initInfobaseOptions.additionalInitializationSteps.length == 0) {
|
if (config.initInfoBaseOptions.additionalInitializationSteps.length == 0) {
|
||||||
FileWrapper[] files = steps.findFiles("tools/vrunner.init*.json")
|
FileWrapper[] files = steps.findFiles("tools/vrunner.init*.json")
|
||||||
files = files.sort new OrderBy( { it.name })
|
files = files.sort new OrderBy( { it.name })
|
||||||
files.each {
|
files.each {
|
||||||
@@ -60,7 +60,7 @@ class InitInfobase implements Serializable {
|
|||||||
VRunner.exec("$vrunnerPath vanessa --settings ${it.path} --ibconnection \"/F./build/ib\"")
|
VRunner.exec("$vrunnerPath vanessa --settings ${it.path} --ibconnection \"/F./build/ib\"")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
config.initInfobaseOptions.additionalInitializationSteps.each {
|
config.initInfoBaseOptions.additionalInitializationSteps.each {
|
||||||
Logger.println("Первичная инициализация командой ${it}")
|
Logger.println("Первичная инициализация командой ${it}")
|
||||||
VRunner.exec("$vrunnerPath ${it} --ibconnection \"/F./build/ib\"")
|
VRunner.exec("$vrunnerPath ${it} --ibconnection \"/F./build/ib\"")
|
||||||
}
|
}
|
@@ -48,8 +48,8 @@ class ConfigurationReaderTest {
|
|||||||
assertThat(jobConfiguration.getSmokeTestOptions().isPublishToAllureReport()).isFalse();
|
assertThat(jobConfiguration.getSmokeTestOptions().isPublishToAllureReport()).isFalse();
|
||||||
assertThat(jobConfiguration.getSmokeTestOptions().isPublishToJUnitReport()).isTrue();
|
assertThat(jobConfiguration.getSmokeTestOptions().isPublishToJUnitReport()).isTrue();
|
||||||
|
|
||||||
assertThat(jobConfiguration.getInitInfobaseOptions().getRunMigration()).isFalse();
|
assertThat(jobConfiguration.getInitInfoBaseOptions().getRunMigration()).isFalse();
|
||||||
assertThat(jobConfiguration.getInitInfobaseOptions().getAdditionalInitializationSteps()).contains("vanessa --settings ./tools/vrunner.first.json");
|
assertThat(jobConfiguration.getInitInfoBaseOptions().getAdditionalInitializationSteps()).contains("vanessa --settings ./tools/vrunner.first.json");
|
||||||
|
|
||||||
assertThat(jobConfiguration.getBddOptions().getVrunnerSteps()).contains("vanessa --settings ./tools/vrunner.json");
|
assertThat(jobConfiguration.getBddOptions().getVrunnerSteps()).contains("vanessa --settings ./tools/vrunner.json");
|
||||||
|
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
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.steps.InitInfobase
|
import ru.pulsar.jenkins.library.steps.InitInfoBase
|
||||||
|
|
||||||
def call(JobConfiguration config) {
|
def call(JobConfiguration config) {
|
||||||
ContextRegistry.registerDefaultContext(this)
|
ContextRegistry.registerDefaultContext(this)
|
||||||
|
|
||||||
def initInfobase = new InitInfobase(config)
|
def initInfobase = new InitInfoBase(config)
|
||||||
initInfobase.run()
|
initInfobase.run()
|
||||||
}
|
}
|
@@ -48,7 +48,7 @@ void call() {
|
|||||||
}
|
}
|
||||||
when {
|
when {
|
||||||
beforeAgent true
|
beforeAgent true
|
||||||
expression { config.stageFlags.needInfobase() }
|
expression { config.stageFlags.needInfoBase() }
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
@@ -58,7 +58,7 @@ void call() {
|
|||||||
}
|
}
|
||||||
when {
|
when {
|
||||||
beforeAgent true
|
beforeAgent true
|
||||||
expression { config.stageFlags.needInfobase() && config.infobaseFromFiles() && config.sourceFormat == SourceFormat.EDT }
|
expression { config.stageFlags.needInfoBase() && config.infoBaseFromFiles() && config.sourceFormat == SourceFormat.EDT }
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
timeout(time: config.timeoutOptions.edtToDesignerFormatTransformation, unit: TimeUnit.MINUTES) {
|
timeout(time: config.timeoutOptions.edtToDesignerFormatTransformation, unit: TimeUnit.MINUTES) {
|
||||||
@@ -73,7 +73,7 @@ void call() {
|
|||||||
createDir('build/out')
|
createDir('build/out')
|
||||||
|
|
||||||
script {
|
script {
|
||||||
if (config.infobaseFromFiles()) {
|
if (config.infoBaseFromFiles()) {
|
||||||
// Создание базы загрузкой из файлов
|
// Создание базы загрузкой из файлов
|
||||||
initFromFiles config
|
initFromFiles config
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user