Skip to content

Commit

Permalink
пgeneralize archive infobase
Browse files Browse the repository at this point in the history
  • Loading branch information
ovcharenko-di committed Jan 18, 2025
1 parent ca6b1b4 commit b92c12e
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 25 deletions.
15 changes: 13 additions & 2 deletions resources/globalConfiguration.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,32 @@
"additionalInitializationSteps": [],
"templateDBPath": "",
"vrunnerSettings": "./tools/vrunner.json",
"archiveInfobase": false,
"archiveInfobase": {
"onAlways": false,
"onFailure": true,
"onUnstable": false,
"onSuccess": false
},
"extensions": []
},
"bdd": {
"vrunnerSteps": [
"vanessa --settings ./tools/vrunner.json"
],
"archiveInfobase": {
"onAlways": false,
"onFailure": true,
"onUnstable": false,
"onSuccess": false
},
"coverage": false,
"dbgsPort": 1550
},
"sonarqube": {
"sonarQubeInstallation": "",
"useSonarScannerFromPath": true,
"sonarScannerToolName": "sonar-scanner",
"infoBaseUpdateModuleName" : "",
"infoBaseUpdateModuleName": "",
"branchAnalysisConfiguration": "fromEnv",
"waitForQualityGate": false
},
Expand Down
55 changes: 43 additions & 12 deletions resources/schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
{
"$schema" : "http://json-schema.org/draft-07/schema#",
"definitions" : {
"ArchiveInfobaseOptions" : {
"type" : "object",
"properties" : {
"onAlways" : {
"type" : "boolean",
"description" : "Сохранять всегда"
},
"onFailure" : {
"type" : "boolean",
"description" : "Сохранять при падении сборки"
},
"onSuccess" : {
"type" : "boolean",
"description" : "Сохранять при успешной сборке"
},
"onUnstable" : {
"type" : "boolean",
"description" : "Сохранять при нестабильной сборке"
}
}
},
"EmailExtConfiguration" : {
"type" : "object",
"properties" : {
Expand Down Expand Up @@ -28,15 +49,22 @@
"bdd" : {
"type" : "object",
"properties" : {
"archiveInfobase" : {
"allOf" : [ {
"$ref" : "#/definitions/ArchiveInfobaseOptions"
}, {
"description" : "Настройки сохранения базы после выполнения всех шагов\n "
} ]
},
"coverage" : {
"type" : "boolean",
"description" : "Выполнять замер покрытия",
"default" : false
"default" : "false"
},
"dbgsPort" : {
"type" : "integer",
"description" : "Порт, на котором будет запущен сервер отладки для замера покрытия",
"default" : 1550
"default" : "1550"
},
"vrunnerSteps" : {
"description" : "Шаги, запускаемые через vrunner.\n В каждой строке передается отдельная команда \n vrunner и ее аргументы (например, \"vanessa --settings ./tools/vrunner.json\").\n По умолчанию содержит одну команду \"vanessa --settings ./tools/vrunner.json\".\n ",
Expand Down Expand Up @@ -80,6 +108,13 @@
"type" : "string"
}
},
"archiveInfobase" : {
"allOf" : [ {
"$ref" : "#/definitions/ArchiveInfobaseOptions"
}, {
"description" : "Настройки сохранения базы после выполнения всех шагов\n "
} ]
},
"extensions" : {
"description" : "Массив расширений для загрузки в конфигурацию.",
"type" : "array",
Expand Down Expand Up @@ -119,10 +154,6 @@
"type" : "boolean",
"description" : "Запустить миграцию ИБ"
},
"archiveInfobase" : {
"type" : "boolean",
"description" : "\n Сохранить базу после выполнения всех шагов инициализации\n "
},
"templateDBPath" : {
"type" : "string",
"description" : "\n Путь к файлу эталонной базы данных.\n * По умолчанию не заполнен;\n * Указывается путь к файлу *.dt или *.1CD.\n "
Expand Down Expand Up @@ -254,12 +285,12 @@
"coverage" : {
"type" : "boolean",
"description" : "Выполнять замер покрытия",
"default" : false
"default" : "false"
},
"dbgsPort" : {
"type" : "integer",
"description" : "Порт, на котором будет запущен сервер отладки для замера покрытия",
"default" : 1550
"default" : "1550"
},
"publishToAllureReport" : {
"type" : "boolean",
Expand Down Expand Up @@ -385,12 +416,12 @@
"publishToAllureReport" : {
"type" : "boolean",
"description" : "Выполнять публикацию результатов в отчет Allure.\n По умолчанию выключено.\n ",
"default": false
"default" : "false"
},
"publishToJUnitReport" : {
"type" : "boolean",
"description" : "Выполнять публикацию результатов в отчет JUnit.\n По умолчанию включено.\n ",
"default": true
"default" : "true"
},
"vrunnerSettings" : {
"type" : "string",
Expand Down Expand Up @@ -479,12 +510,12 @@
"coverage" : {
"type" : "boolean",
"description" : "Выполнять замер покрытия",
"default" : false
"default" : "false"
},
"dbgsPort" : {
"type" : "integer",
"description" : "Порт, на котором будет запущен сервер отладки для замера покрытия",
"default" : 1550
"default" : "1550"
},
"publishToAllureReport" : {
"type" : "boolean",
Expand Down
3 changes: 2 additions & 1 deletion src/JobConfigurationSchemaGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public static void main(String[] args) {
writer.write(jsonSchema.toPrettyString());
System.out.println(jsonSchema.toPrettyString());
} catch (IOException e) {
e.printStackTrace();
//noinspection CallToPrintStackTrace
e.printStackTrace();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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 ArchiveInfobaseOptions implements Serializable {

@JsonPropertyDescription("Сохранять всегда")
Boolean onAlways = false
@JsonPropertyDescription("Сохранять при успешной сборке")
Boolean onSuccess = false
@JsonPropertyDescription("Сохранять при падении сборки")
Boolean onFailure = false
@JsonPropertyDescription("Сохранять при нестабильной сборке")
Boolean onUnstable = false

@Override
@NonCPS
String toString() {
return "ArchiveInfobaseOptions{" +
"onAlways=" + onAlways +
", onSuccess=" + onSuccess +
", onFailure=" + onFailure +
", onUnstable=" + onUnstable +
'}';
}
}


5 changes: 5 additions & 0 deletions src/ru/pulsar/jenkins/library/configuration/BddOptions.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ class BddOptions extends StepCoverageOptions implements Serializable {
'vanessa --settings ./tools/vrunner.json'
]

@JsonPropertyDescription("""Настройки сохранения базы после выполнения всех шагов
""")
ArchiveInfobaseOptions archiveInfobase

@Override
@NonCPS
String toString() {
return "BddOptions{" +
"vrunnerSteps=" + vrunnerSteps +
"archiveInfobase=" + archiveInfobase +
"coverage=" + coverage +
"dbgsPort=" + dbgsPort +
'}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ class InitInfoBaseOptions implements Serializable {
""")
String templateDBPath

@JsonPropertyDescription("""
Сохранить базу после выполнения всех шагов инициализации
@JsonPropertyDescription("""Настройки сохранения базы после выполнения всех шагов
""")
Boolean archiveInfobase
ArchiveInfobaseOptions archiveInfobase

@JsonPropertyDescription("Массив расширений для загрузки в конфигурацию.")
Extension[] extensions
Expand Down
41 changes: 41 additions & 0 deletions src/ru/pulsar/jenkins/library/steps/ZipInfobase.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package ru.pulsar.jenkins.library.steps

import hudson.model.Result
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 ZipInfobase implements Serializable {

private final JobConfiguration config
private final String stage

ZipInfobase(JobConfiguration config, String stage) {
this.config = config
this.stage = stage
}

def run() {
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()

Logger.printLocation()

def currentBuild = steps.currentBuild()
def currentResult = Result.fromString(currentBuild.getCurrentResult())

def archiveInfobaseOptions = options.archiveInfobase

def archiveInfobase = false
if (archiveInfobaseOptions.onAlways
|| (archiveInfobaseOptions.onFailure && (currentResult == Result.FAILURE || currentResult == Result.ABORTED))
|| (archiveInfobaseOptions.onUnstable && currentResult == Result.UNSTABLE)
|| (archiveInfobaseOptions.onSuccess && currentResult == Result.SUCCESS)) {
archiveInfobase = true
}

def archiveName = "1Cv8.1CD.${stage}.zip"
steps.zip('build/ib', '1Cv8.1CD', archiveName, archiveInfobase)
steps.stash(archiveName, archiveName, false)
}
}
2 changes: 1 addition & 1 deletion vars/pipeline1C.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void call() {
timeout(time: config.timeoutOptions.zipInfoBase, unit: TimeUnit.MINUTES) {
printLocation()

zipInfobase(config)
zipInfobase config, 'initInfobase'
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions vars/zipInfobase.groovy
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import ru.pulsar.jenkins.library.configuration.JobConfiguration
import ru.pulsar.jenkins.library.ioc.ContextRegistry
import ru.pulsar.jenkins.library.steps.ZipInfobase

def call(JobConfiguration config) {

def archiveName = '1Cv8.1CD.zip'

zip dir: 'build/ib', glob: '1Cv8.1CD', zipFile: archiveName, archive: config.initInfoBaseOptions.archiveInfobase
stash name: archiveName, includes: archiveName, allowEmpty: false
def call(JobConfiguration config, String stageName) {
ContextRegistry.registerDefaultContext(this)

def zipInfobase = new ZipInfobase(config, stageName)
zipInfobase.run()
}

0 comments on commit b92c12e

Please sign in to comment.