mirror of
https://github.com/firstBitMarksistskaya/jenkins-lib.git
synced 2025-02-01 13:28:00 +02:00
Шаг инициализации информационной базы
This commit is contained in:
parent
1f41708d04
commit
1a116ee66e
@ -6,11 +6,16 @@
|
|||||||
"storage": "UNKNOWN_ID"
|
"storage": "UNKNOWN_ID"
|
||||||
},
|
},
|
||||||
"stages": {
|
"stages": {
|
||||||
|
"initSteps": false,
|
||||||
"sonarqube": false,
|
"sonarqube": false,
|
||||||
"syntaxCheck": false,
|
"syntaxCheck": false,
|
||||||
"edtValidate": false,
|
"edtValidate": false,
|
||||||
"smoke": false
|
"smoke": false
|
||||||
},
|
},
|
||||||
|
"initInfobase": {
|
||||||
|
"runMigration": true,
|
||||||
|
"additionalMigrationSteps": []
|
||||||
|
},
|
||||||
"sonarqube": {
|
"sonarqube": {
|
||||||
"sonarQubeInstallation": "",
|
"sonarQubeInstallation": "",
|
||||||
"useSonarScannerFromPath": true,
|
"useSonarScannerFromPath": true,
|
||||||
|
@ -45,6 +45,28 @@
|
|||||||
"smoke" : {
|
"smoke" : {
|
||||||
"type" : "boolean",
|
"type" : "boolean",
|
||||||
"description" : "Дымовые тесты включены"
|
"description" : "Дымовые тесты включены"
|
||||||
|
},
|
||||||
|
"initSteps" : {
|
||||||
|
"type" : "boolean",
|
||||||
|
"description" : "Предварительные шаги инициализации включены"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"initInfobase" : {
|
||||||
|
"type" : "object",
|
||||||
|
"id" : "urn:jsonschema:ru:pulsar:jenkins:library:configuration:InitInfobaseOptions",
|
||||||
|
"description" : "Настройки шага инициализации ИБ",
|
||||||
|
"properties" : {
|
||||||
|
"runMigration" : {
|
||||||
|
"type" : "boolean",
|
||||||
|
"description" : "Запустить миграцию ИБ"
|
||||||
|
},
|
||||||
|
"additionalMigrationSteps" : {
|
||||||
|
"type" : "array",
|
||||||
|
"description" : "Дополнительные шаги, запускаемые через vrunner.\n В каждой строке передается отдельная команда \n vrunner и ее аргументы (например, \"vanessa --settings ./tools/vrunner.first.json\")\n ",
|
||||||
|
"items" : {
|
||||||
|
"type" : "string"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -41,12 +41,14 @@ class ConfigurationReader implements Serializable {
|
|||||||
def nonMergeableSettings = Arrays.asList(
|
def nonMergeableSettings = Arrays.asList(
|
||||||
"secrets",
|
"secrets",
|
||||||
"stageFlags",
|
"stageFlags",
|
||||||
|
"initInfobaseOptions",
|
||||||
"sonarQubeOptions",
|
"sonarQubeOptions",
|
||||||
"syntaxCheckOptions",
|
"syntaxCheckOptions",
|
||||||
"resultsTransformOptions"
|
"resultsTransformOptions"
|
||||||
).toSet()
|
).toSet()
|
||||||
|
|
||||||
mergeObjects(baseConfiguration, configurationToMerge, nonMergeableSettings)
|
mergeObjects(baseConfiguration, configurationToMerge, nonMergeableSettings)
|
||||||
|
mergeInitInfobaseOptions(baseConfiguration.initInfobaseOptions, configurationToMerge.initInfobaseOptions);
|
||||||
|
|
||||||
return baseConfiguration;
|
return baseConfiguration;
|
||||||
}
|
}
|
||||||
@ -70,4 +72,9 @@ class ConfigurationReader implements Serializable {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonCPS
|
||||||
|
private static void mergeInitInfobaseOptions(InitInfobaseOptions baseObject, InitInfobaseOptions objectToMerge) {
|
||||||
|
baseObject.additionalMigrationSteps = objectToMerge.additionalMigrationSteps.clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package ru.pulsar.jenkins.library.configuration
|
||||||
|
|
||||||
|
import com.cloudbees.groovy.cps.NonCPS
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
|
import com.fasterxml.jackson.annotation.JsonPropertyDescription
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
class InitInfobaseOptions implements Serializable {
|
||||||
|
|
||||||
|
@JsonPropertyDescription("Запустить миграцию ИБ")
|
||||||
|
boolean runMigration = true
|
||||||
|
|
||||||
|
@JsonPropertyDescription("""Дополнительные шаги, запускаемые через vrunner.
|
||||||
|
В каждой строке передается отдельная команда
|
||||||
|
vrunner и ее аргументы (например, "vanessa --settings ./tools/vrunner.first.json")
|
||||||
|
""")
|
||||||
|
String[] additionalMigrationSteps
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NonCPS
|
||||||
|
String toString() {
|
||||||
|
return "InitInfobaseOptions{" +
|
||||||
|
"runMigration=" + runMigration +
|
||||||
|
", additionalMigrationSteps=" + additionalMigrationSteps +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,10 @@ class JobConfiguration implements Serializable {
|
|||||||
@JsonPropertyDescription("Идентификаторы сохраненных секретов")
|
@JsonPropertyDescription("Идентификаторы сохраненных секретов")
|
||||||
Secrets secrets;
|
Secrets secrets;
|
||||||
|
|
||||||
|
@JsonProperty("initInfobase")
|
||||||
|
@JsonPropertyDescription("Настройки шага инициализации ИБ")
|
||||||
|
InitInfobaseOptions initInfobaseOptions;
|
||||||
|
|
||||||
@JsonProperty("sonarqube")
|
@JsonProperty("sonarqube")
|
||||||
@JsonPropertyDescription("Настройки анализа SonarQube")
|
@JsonPropertyDescription("Настройки анализа SonarQube")
|
||||||
SonarQubeOptions sonarQubeOptions;
|
SonarQubeOptions sonarQubeOptions;
|
||||||
@ -40,6 +44,7 @@ class JobConfiguration implements Serializable {
|
|||||||
", srcDir='" + srcDir + '\'' +
|
", srcDir='" + srcDir + '\'' +
|
||||||
", stageFlags=" + stageFlags +
|
", stageFlags=" + stageFlags +
|
||||||
", secrets=" + secrets +
|
", secrets=" + secrets +
|
||||||
|
", initInfobaseOptions=" + initInfobaseOptions +
|
||||||
", sonarQubeOptions=" + sonarQubeOptions +
|
", sonarQubeOptions=" + sonarQubeOptions +
|
||||||
", syntaxCheckOptions=" + syntaxCheckOptions +
|
", syntaxCheckOptions=" + syntaxCheckOptions +
|
||||||
", resultsTransformOptions=" + resultsTransformOptions +
|
", resultsTransformOptions=" + resultsTransformOptions +
|
||||||
|
@ -18,6 +18,9 @@ class StageFlags implements Serializable {
|
|||||||
@JsonPropertyDescription("Дымовые тесты включены")
|
@JsonPropertyDescription("Дымовые тесты включены")
|
||||||
boolean smoke
|
boolean smoke
|
||||||
|
|
||||||
|
@JsonPropertyDescription("Предварительные шаги инициализации включены")
|
||||||
|
boolean initSteps
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonCPS
|
@NonCPS
|
||||||
String toString() {
|
String toString() {
|
||||||
@ -26,10 +29,11 @@ class StageFlags implements Serializable {
|
|||||||
", syntaxCheck=" + syntaxCheck +
|
", syntaxCheck=" + syntaxCheck +
|
||||||
", edtValidate=" + edtValidate +
|
", edtValidate=" + edtValidate +
|
||||||
", smoke=" + smoke +
|
", smoke=" + smoke +
|
||||||
|
", initSteps=" + initSteps +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean needInfobase() {
|
boolean needInfobase() {
|
||||||
return smoke || syntaxCheck
|
return smoke || syntaxCheck || initSteps
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
40
src/ru/pulsar/jenkins/library/steps/InitInfobase.groovy
Normal file
40
src/ru/pulsar/jenkins/library/steps/InitInfobase.groovy
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package ru.pulsar.jenkins.library.steps
|
||||||
|
|
||||||
|
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.Logger
|
||||||
|
|
||||||
|
class InitInfobase implements Serializable {
|
||||||
|
|
||||||
|
private final JobConfiguration config;
|
||||||
|
|
||||||
|
InitInfobase(JobConfiguration config) {
|
||||||
|
this.config = config
|
||||||
|
}
|
||||||
|
|
||||||
|
def run() {
|
||||||
|
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||||
|
|
||||||
|
Logger.printLocation()
|
||||||
|
|
||||||
|
if (!config.stageFlags.initSteps) {
|
||||||
|
Logger.println("Init step is disabled")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.initInfobaseOptions.runMigration) {
|
||||||
|
Logger.println("Запуск миграции ИБ")
|
||||||
|
|
||||||
|
// Запуск миграции
|
||||||
|
steps.cmd("oscript_modules/bin/vrunner run --command \"ЗапуститьОбновлениеИнформационнойБазы;ЗавершитьРаботуСистемы;\" --execute \$runnerRoot/epf/ЗакрытьПредприятие.epf --ibconnection \"/F./build/ib\"")
|
||||||
|
} else {
|
||||||
|
Logger.println("Шаг миграции ИБ выключен")
|
||||||
|
}
|
||||||
|
|
||||||
|
config.initInfobaseOptions.additionalMigrationSteps.each {
|
||||||
|
Logger.println("Первичная инициализация командой ${it}")
|
||||||
|
steps.cmd("oscript_modules/bin/vrunner ${it}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -31,14 +31,21 @@ class ConfigurationReaderTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(jobConfiguration.getV8version()).isEqualTo("8.3.14.1944");
|
assertThat(jobConfiguration.getV8version()).isEqualTo("8.3.14.1944");
|
||||||
|
|
||||||
assertThat(jobConfiguration.getSonarQubeOptions().getSonarScannerToolName()).isEqualTo("sonar-scanner");
|
assertThat(jobConfiguration.getSonarQubeOptions().getSonarScannerToolName()).isEqualTo("sonar-scanner");
|
||||||
|
|
||||||
assertThat(jobConfiguration.getSecrets())
|
assertThat(jobConfiguration.getSecrets())
|
||||||
.hasFieldOrPropertyWithValue("storage", "1234")
|
.hasFieldOrPropertyWithValue("storage", "1234")
|
||||||
.hasFieldOrPropertyWithValue("storagePath", "UNKNOWN_ID")
|
.hasFieldOrPropertyWithValue("storagePath", "UNKNOWN_ID")
|
||||||
;
|
;
|
||||||
|
|
||||||
assertThat(jobConfiguration.getSyntaxCheckOptions().getCheckModes()).hasSize(1);
|
assertThat(jobConfiguration.getSyntaxCheckOptions().getCheckModes()).hasSize(1);
|
||||||
|
|
||||||
assertThat(jobConfiguration.getResultsTransformOptions().isRemoveSupport()).isTrue();
|
assertThat(jobConfiguration.getResultsTransformOptions().isRemoveSupport()).isTrue();
|
||||||
assertThat(jobConfiguration.getResultsTransformOptions().getSupportLevel()).isEqualTo(0);
|
assertThat(jobConfiguration.getResultsTransformOptions().getSupportLevel()).isZero();
|
||||||
|
|
||||||
|
assertThat(jobConfiguration.getInitInfobaseOptions().getRunMigration()).isFalse();
|
||||||
|
assertThat(jobConfiguration.getInitInfobaseOptions().getAdditionalMigrationSteps()).contains("vanessa --settings ./tools/vrunner.first.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -6,6 +6,12 @@
|
|||||||
"stages": {
|
"stages": {
|
||||||
"syntaxCheck": true
|
"syntaxCheck": true
|
||||||
},
|
},
|
||||||
|
"initInfobase": {
|
||||||
|
"runMigration": false,
|
||||||
|
"additionalMigrationSteps": [
|
||||||
|
"vanessa --settings ./tools/vrunner.first.json"
|
||||||
|
]
|
||||||
|
},
|
||||||
"syntaxCheck": {
|
"syntaxCheck": {
|
||||||
"checkModes": ["-ThinClient"]
|
"checkModes": ["-ThinClient"]
|
||||||
},
|
},
|
||||||
|
10
vars/initInfobase.groovy
Normal file
10
vars/initInfobase.groovy
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||||
|
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||||
|
import ru.pulsar.jenkins.library.steps.InitInfobase
|
||||||
|
|
||||||
|
def call(JobConfiguration config) {
|
||||||
|
ContextRegistry.registerDefaultContext(this)
|
||||||
|
|
||||||
|
def initInfobase = new InitInfobase(config)
|
||||||
|
initInfobase.run()
|
||||||
|
}
|
@ -46,18 +46,43 @@ void call() {
|
|||||||
expression { config.stageFlags.needInfobase() }
|
expression { config.stageFlags.needInfobase() }
|
||||||
}
|
}
|
||||||
|
|
||||||
steps {
|
stages {
|
||||||
printLocation()
|
stage('Создание ИБ') {
|
||||||
|
steps {
|
||||||
|
printLocation()
|
||||||
|
|
||||||
installLocalDependencies()
|
installLocalDependencies()
|
||||||
|
|
||||||
dir("build/out") { echo '' }
|
dir("build/out") { echo '' }
|
||||||
|
|
||||||
// Создание базы загрузкой конфигурации из хранилища
|
// Создание базы загрузкой конфигурации из хранилища
|
||||||
initFromStorage config
|
initFromStorage config
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
zipInfobase()
|
stage('Инициализация ИБ') {
|
||||||
|
when {
|
||||||
|
beforeAgent true
|
||||||
|
expression { config.stageFlags.initSteps }
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
printLocation()
|
||||||
|
|
||||||
|
// Инициализация и первичная миграция
|
||||||
|
initInfobase config
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Архивация ИБ') {
|
||||||
|
steps {
|
||||||
|
printLocation()
|
||||||
|
|
||||||
|
zipInfobase()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Трансформация в формат EDT') {
|
stage('Трансформация в формат EDT') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user