mirror of
https://github.com/firstBitMarksistskaya/jenkins-lib.git
synced 2025-02-12 14:57:15 +02:00
Рефакторинг
This commit is contained in:
commit
aa82bd09ec
@ -10,7 +10,7 @@ class JobConfiguration implements Serializable {
|
||||
@JsonPropertyDescription("Версия платформы 1С:Предприятие в формате 8.3.хх.хххх.")
|
||||
String v8version
|
||||
|
||||
@JsonPropertyDescription("Путь к корневому каталогу с исходниками конфигурации")
|
||||
@JsonPropertyDescription("Путь к корневому каталогу с исходниками конфигурации, в случае хранения исходников в формате EDT, необходимо указать путь к проекту")
|
||||
String srcDir
|
||||
|
||||
@JsonPropertyDescription("Формат исходников конфигурации")
|
||||
@ -64,4 +64,8 @@ class JobConfiguration implements Serializable {
|
||||
", logosConfig=" + logosConfig +
|
||||
'}';
|
||||
}
|
||||
|
||||
boolean infobaseFromFiles(){
|
||||
return sourceFormat.EDT
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||
import ru.pulsar.jenkins.library.utils.Logger
|
||||
|
||||
class EdtTransform implements Serializable {
|
||||
class DesignerToEdtFormatTransformation implements Serializable {
|
||||
|
||||
public static final String PROJECT_NAME = 'temp'
|
||||
public static final String WORKSPACE = 'build/edt-workspace'
|
||||
@ -15,7 +15,7 @@ class EdtTransform implements Serializable {
|
||||
|
||||
private final JobConfiguration config;
|
||||
|
||||
EdtTransform(JobConfiguration config) {
|
||||
DesignerToEdtFormatTransformation(JobConfiguration config) {
|
||||
this.config = config
|
||||
}
|
||||
|
@ -4,18 +4,19 @@ 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.Constants
|
||||
import ru.pulsar.jenkins.library.utils.Logger
|
||||
|
||||
class EdtBackTransform implements Serializable {
|
||||
class EdtToDesignerFormatTransformation implements Serializable {
|
||||
|
||||
public static final String WORKSPACE = 'build/workcspace'
|
||||
public static final String WORKSPACE = 'build/edt-workspace'
|
||||
public static final String CONFIGURATION_DIR = 'build/cfg'
|
||||
public static final String CONFIGURATION_ZIP = 'build/cfg.zip'
|
||||
public static final String CONFIGURATION_ZIP_STASH = 'cfg-zip'
|
||||
|
||||
private final JobConfiguration config;
|
||||
|
||||
EdtBackTransform(JobConfiguration config) {
|
||||
EdtToDesignerFormatTransformation(JobConfiguration config) {
|
||||
this.config = config
|
||||
}
|
||||
|
||||
@ -24,8 +25,8 @@ class EdtBackTransform implements Serializable {
|
||||
|
||||
Logger.printLocation()
|
||||
|
||||
if (!config.stageFlags.srcEDT) {
|
||||
Logger.println("SRC is not EDT format. No transform is needed.")
|
||||
if (!config.sourceFormat.EDT) {
|
||||
Logger.println("SRC is not in EDT format. No transform is needed.")
|
||||
return
|
||||
}
|
||||
|
||||
@ -43,7 +44,7 @@ class EdtBackTransform implements Serializable {
|
||||
|
||||
def ringCommand = "ring edt workspace export --configuration-files '$configurationRoot' --project $projectDir --workspace-location '$workspaceDir'"
|
||||
|
||||
def ringOpts = ['RING_OPTS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru']
|
||||
def ringOpts =[Constants.DEFAULT_RING_OPTS]
|
||||
steps.withEnv(ringOpts) {
|
||||
steps.cmd(ringCommand)
|
||||
}
|
@ -26,26 +26,26 @@ class EdtValidate implements Serializable {
|
||||
return
|
||||
}
|
||||
|
||||
steps.unstash(EdtTransform.WORKSPACE_ZIP_STASH)
|
||||
steps.unzip(EdtTransform.WORKSPACE, EdtTransform.WORKSPACE_ZIP)
|
||||
steps.unstash(DesignerToEdtFormatTransformation.WORKSPACE_ZIP_STASH)
|
||||
steps.unzip(DesignerToEdtFormatTransformation.WORKSPACE, DesignerToEdtFormatTransformation.WORKSPACE_ZIP)
|
||||
|
||||
def env = steps.env();
|
||||
|
||||
def resultFile = "$env.WORKSPACE/$RESULT_FILE"
|
||||
def workspaceLocation = "$env.WORKSPACE/$EdtTransform.WORKSPACE"
|
||||
def workspaceLocation = "$env.WORKSPACE/$DesignerToEdtFormatTransformation.WORKSPACE"
|
||||
|
||||
steps.createDir(new File(resultFile).getParent())
|
||||
|
||||
Logger.println("Выполнение валидации EDT")
|
||||
|
||||
def ringCommand = "ring edt workspace validate --workspace-location '$workspaceLocation' --file '$resultFile' --project-name-list $EdtTransform.PROJECT_NAME"
|
||||
def ringCommand = "ring edt workspace validate --workspace-location '$workspaceLocation' --file '$resultFile' --project-name-list $DesignerToEdtFormatTransformation.PROJECT_NAME"
|
||||
def ringOpts = ['RING_OPTS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru']
|
||||
steps.withEnv(ringOpts) {
|
||||
steps.catchError {
|
||||
steps.cmd(ringCommand)
|
||||
}
|
||||
}
|
||||
steps.archiveArtifacts("$EdtTransform.WORKSPACE/.metadata/.log")
|
||||
steps.archiveArtifacts("$DesignerToEdtFormatTransformation.WORKSPACE/.metadata/.log")
|
||||
steps.archiveArtifacts(RESULT_FILE)
|
||||
steps.stash(RESULT_STASH, RESULT_FILE)
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class InitFromFiles implements Serializable {
|
||||
|
||||
Logger.printLocation()
|
||||
|
||||
if (!config.stageFlags.infobaseFromFiles()) {
|
||||
if (!config.infobaseFromFiles()) {
|
||||
Logger.println("init infoBase from files is disabled")
|
||||
return
|
||||
}
|
||||
@ -27,10 +27,10 @@ class InitFromFiles implements Serializable {
|
||||
|
||||
def env = steps.env();
|
||||
|
||||
def srcDir = "$env.WORKSPACE/$EdtBackTransform.CONFIGURATION_DIR"
|
||||
def srcDir = "$env.WORKSPACE/$EdtToDesignerFormatTransformation.CONFIGURATION_DIR"
|
||||
|
||||
steps.unstash(EdtBackTransform.CONFIGURATION_ZIP_STASH)
|
||||
steps.unzip(srcDir, EdtBackTransform.CONFIGURATION_ZIP)
|
||||
steps.unstash(EdtToDesignerFormatTransformation.CONFIGURATION_ZIP_STASH)
|
||||
steps.unzip(srcDir, EdtToDesignerFormatTransformation.CONFIGURATION_ZIP)
|
||||
|
||||
Logger.println("Выполнение загрузки конфигурации из файлов")
|
||||
def initCommand = "oscript_modules/bin/vrunner init-dev --src $srcDir --ibconnection \"/F./build/ib\""
|
||||
|
@ -9,11 +9,15 @@ import ru.pulsar.jenkins.library.utils.VersionParser
|
||||
class SonarScanner implements Serializable {
|
||||
|
||||
private final JobConfiguration config;
|
||||
private String rootFile
|
||||
private final String rootFile
|
||||
|
||||
SonarScanner(JobConfiguration config) {
|
||||
this.config = config
|
||||
this.rootFile = "$config.srcDir/Configuration.xml"
|
||||
if (config.sourceFormat.EDT){
|
||||
this.rootFile = "$config.srcDir/src/Configuration/Configuration.mdo"
|
||||
} else {
|
||||
this.rootFile = "$config.srcDir/Configuration.xml"
|
||||
}
|
||||
}
|
||||
|
||||
def run() {
|
||||
@ -40,8 +44,7 @@ class SonarScanner implements Serializable {
|
||||
String sonarCommand = "$sonarScannerBinary -Dsonar.branch.name=$env.BRANCH_NAME"
|
||||
|
||||
String configurationVersion = ""
|
||||
if (config.stageFlags.srcEDT) {
|
||||
rootFile = "$config.srcDir/Configuration/Configuration.mdo"
|
||||
if (config.sourceFormat.EDT) {
|
||||
configurationVersion = VersionParser.edt(rootFile)
|
||||
}else {
|
||||
configurationVersion = VersionParser.configuration(rootFile)
|
||||
|
6
src/ru/pulsar/jenkins/library/utils/Constants.groovy
Normal file
6
src/ru/pulsar/jenkins/library/utils/Constants.groovy
Normal file
@ -0,0 +1,6 @@
|
||||
package ru.pulsar.jenkins.library.utils
|
||||
|
||||
final class Constants {
|
||||
public static final String DEFAULT_RING_OPTS = "RING_OPTS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru"
|
||||
}
|
||||
|
@ -17,6 +17,14 @@ class VersionParser implements Serializable {
|
||||
return version(configurationText, VERSION_REGEXP)
|
||||
}
|
||||
|
||||
static String edt(rootFile = 'src/Configuration/Configuration.mdo') {
|
||||
|
||||
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||
|
||||
def configurationText = steps.readFile(rootFile, 'UTF-8');
|
||||
return version(configurationText, VERSION_REGEXP)
|
||||
}
|
||||
|
||||
static String storage(versionFile = 'src/cf/VERSION') {
|
||||
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||
|
||||
@ -30,12 +38,4 @@ class VersionParser implements Serializable {
|
||||
return matcher != null && matcher.getCount() == 1 ? matcher[0][1] : ""
|
||||
}
|
||||
|
||||
static String edt(rootFile = 'src/Configuration/Configuration.mdo') {
|
||||
|
||||
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
|
||||
|
||||
def configurationText = steps.readFile(rootFile, 'UTF-8');
|
||||
return version(configurationText, VERSION_REGEXP)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||
import ru.pulsar.jenkins.library.steps.EdtTransform
|
||||
import ru.pulsar.jenkins.library.steps.DesignerToEdtFormatTransformation
|
||||
|
||||
def call(JobConfiguration config) {
|
||||
ContextRegistry.registerDefaultContext(this)
|
||||
|
||||
def edtTransform = new EdtTransform(config)
|
||||
def edtTransform = new DesignerToEdtFormatTransformation(config)
|
||||
edtTransform.run()
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||
import ru.pulsar.jenkins.library.steps.EdtBackTransform
|
||||
import ru.pulsar.jenkins.library.steps.EdtToDesignerFormatTransformation
|
||||
|
||||
def call(JobConfiguration config) {
|
||||
ContextRegistry.registerDefaultContext(this)
|
||||
|
||||
def edtBackTransform = new EdtBackTransform(config)
|
||||
def edtBackTransform = new EdtToDesignerFormatTransformation(config)
|
||||
edtBackTransform.run()
|
||||
}
|
@ -55,31 +55,29 @@ void call() {
|
||||
}
|
||||
when {
|
||||
beforeAgent true
|
||||
expression { config.sourceFormat.infobaseFromFiles() }
|
||||
expression { config.infobaseFromFiles() }
|
||||
}
|
||||
steps {
|
||||
script{
|
||||
edtBackTransform config
|
||||
}
|
||||
edtToDesignerFormatTransformation config
|
||||
}
|
||||
}
|
||||
|
||||
stage('Создание ИБ') {
|
||||
steps {
|
||||
script{
|
||||
printLocation()
|
||||
printLocation()
|
||||
|
||||
installLocalDependencies()
|
||||
installLocalDependencies()
|
||||
|
||||
createDir('build/out')
|
||||
createDir('build/out')
|
||||
|
||||
if (config.sourceFormat.infobaseFromFiles()){
|
||||
script {
|
||||
if (config.infobaseFromFiles()){
|
||||
// Создание базы загрузкой из файлов
|
||||
initFromFiles config
|
||||
}
|
||||
else{
|
||||
// Создание базы загрузкой конфигурации из хранилища
|
||||
initFromStorage config
|
||||
initFromStorage config
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,7 +112,7 @@ void call() {
|
||||
}
|
||||
when {
|
||||
beforeAgent true
|
||||
expression { config.stageFlags.edtValidate && !config.stageFlags.srcEDT}
|
||||
expression { config.sourceFormat.DESIGNER && config.stageFlags.edtValidate}
|
||||
}
|
||||
steps {
|
||||
edtTransform config
|
||||
|
Loading…
x
Reference in New Issue
Block a user