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