1
0
mirror of https://github.com/firstBitMarksistskaya/jenkins-lib.git synced 2025-01-05 13:10:28 +02:00

Переделана модель этапов сборки.

Разделены этапы трансформации в едт, валидации и трансформации результатов
This commit is contained in:
Nikita Gryzlov 2020-04-29 13:09:54 +03:00
parent e4d9d58825
commit 0969f3916f
No known key found for this signature in database
GPG Key ID: C1EAE411FEF0BF2F
7 changed files with 152 additions and 63 deletions

View File

@ -35,4 +35,10 @@ interface IStepExecutor {
def stash(String name, String includes)
def unstash(String name)
def zip(String dir, String zipFile)
def zip(String dir, String zipFile, String glob)
def unzip(String dir, String zipFile)
}

View File

@ -88,4 +88,14 @@ class StepExecutor implements IStepExecutor {
def unstash(String name) {
steps.unstash name
}
@Override
def zip(String dir, String zipFile, String glob = '') {
steps.zip dir: dir, zipFile: zipFile, glob: glob
}
@Override
def unzip(String dir, String zipFile) {
steps.unzip dir: dir, zipFile: zipFile
}
}

View File

@ -0,0 +1,52 @@
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 EdtTransform implements Serializable {
public static final String PROJECT_NAME = 'temp'
public static final String WORKSPACE = 'build/edt-workspace'
public static final String WORKSPACE_ZIP = 'build/edt-workspace.zip'
public static final String WORKSPACE_ZIP_STASH = 'edt-workspace-zip'
private final JobConfiguration config;
private final String rootDir
EdtTransform(JobConfiguration config, String rootDir = 'src/cf') {
this.config = config
this.rootDir = rootDir
}
def run() {
IStepExecutor steps = ContextRegistry.getContext().getStepExecutor()
Logger.printLocation()
if (!config.stageFlags.edtValidate) {
Logger.println("EDT validate step is disabled. No transform is needed.")
return
}
def env = steps.env();
def workspaceDir = "$env.WORKSPACE/$WORKSPACE"
def configurationRoot = new File(env.WORKSPACE, rootDir).getAbsolutePath()
steps.createDir(workspaceDir)
Logger.println("Конвертация исходников из формата конфигуратора в формат EDT")
def ringCommand = "ring edt workspace import --configuration-files '$configurationRoot' --project-name $PROJECT_NAME --workspace-location '$workspaceDir'"
def ringOpts = ['RING_OPTS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru']
steps.withEnv(ringOpts) {
steps.cmd(ringCommand)
}
steps.zip(WORKSPACE, WORKSPACE_ZIP)
steps.stash(WORKSPACE_ZIP_STASH, WORKSPACE_ZIP)
}
}

View File

@ -7,6 +7,9 @@ import ru.pulsar.jenkins.library.utils.Logger
class EdtValidate implements Serializable {
public static final String RESULT_STASH = 'edt-validate'
public static final String RESULT_FILE = 'build/out/edt-validate.out'
private final JobConfiguration config;
private final String rootDir
@ -25,35 +28,25 @@ class EdtValidate implements Serializable {
return
}
steps.unstash(EdtTransform.WORKSPACE_ZIP_STASH)
steps.unzip(EdtTransform.WORKSPACE_ZIP, EdtTransform.WORKSPACE)
def env = steps.env();
def resultFileRelative = 'build/out/edt-validate.out'
def projectName = 'temp'
def workspaceDir = "$env.WORKSPACE/build/workspace"
def resultFile = "$env.WORKSPACE/$resultFileRelative"
def configurationRoot = new File(env.WORKSPACE, rootDir).getAbsolutePath()
def resultFile = "$env.WORKSPACE/$RESULT_FILE"
steps.createDir(workspaceDir)
steps.createDir(new File(resultFile).getParent())
Logger.println("Конвертация исходников из формата конфигуратора в формат EDT")
def ringCommand = "ring edt workspace import --configuration-files '$configurationRoot' --project-name $projectName --workspace-location '$workspaceDir'"
def ringOpts = ['_JAVA_OPTS="-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru"']
steps.withEnv(ringOpts) {
steps.cmd(ringCommand)
}
Logger.println("Выполнение валидации EDT")
ringCommand = "ring edt workspace validate --workspace-location '$workspaceDir' --file '$resultFile' --project-name-list $projectName"
def ringCommand = "ring edt workspace validate --workspace-location '$EdtTransform.WORKSPACE' --file '$resultFile' --project-name-list $EdtTransform.PROJECT_NAME"
def ringOpts = ['RING_OPTIONS=-Dfile.encoding=UTF-8 -Dosgi.nl=ru -Duser.language=ru']
steps.withEnv(ringOpts) {
steps.cmd(ringCommand)
}
steps.archiveArtifacts(resultFileRelative)
steps.stash('edt-validate', resultFileRelative)
steps.archiveArtifacts(RESULT_FILE)
steps.stash(RESULT_STASH, RESULT_FILE)
}
}

View File

@ -7,12 +7,13 @@ import ru.pulsar.jenkins.library.utils.Logger
class ResultsTransformer implements Serializable {
private final JobConfiguration config;
private final String rootDir
public static final String RESULT_STASH = 'edt-generic-issue'
public static final String RESULT_FILE = 'build/out/edt-generic-issue.json'
ResultsTransformer(JobConfiguration config, String rootDir = 'src/cf') {
private final JobConfiguration config;
ResultsTransformer(JobConfiguration config) {
this.config = config
this.rootDir = rootDir
}
def run() {
@ -32,17 +33,19 @@ class ResultsTransformer implements Serializable {
return
}
steps.unstash('edt-validate')
steps.unstash(EdtTransform.WORKSPACE_ZIP_STASH)
steps.unzip(EdtTransform.WORKSPACE_ZIP, EdtTransform.WORKSPACE)
steps.unstash(EdtValidate.RESULT_STASH)
Logger.println("Конвертация результата EDT в Generic Issue")
def genericIssueRelative = "build/out/edt-generic-issue.json"
def edtValidateFile = "$env.WORKSPACE/build/out/edt-validate.out"
def genericIssueFile = "$env.WORKSPACE/$genericIssueRelative"
def edtValidateFile = "$env.WORKSPACE/$EdtValidate.RESULT_FILE"
def genericIssueFile = "$env.WORKSPACE/$RESULT_FILE"
steps.cmd("stebi convert $edtValidateFile $genericIssueFile $rootDir")
steps.cmd("stebi convert $edtValidateFile $genericIssueFile $EdtTransform.WORKSPACE")
steps.archiveArtifacts(genericIssueRelative)
steps.stash('edt-generic-issue', genericIssueRelative)
steps.archiveArtifacts(RESULT_FILE)
steps.stash(RESULT_STASH, RESULT_FILE)
}
}

10
vars/edtTransform.groovy Normal file
View 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.EdtTransform
def call(JobConfiguration config, String rootDir = 'src/cf') {
ContextRegistry.registerDefaultContext(this)
def edtTransform = new EdtTransform(config, rootDir)
edtTransform.run()
}

View File

@ -35,13 +35,13 @@ void call() {
}
}
stage('1C') {
agent {
label agent1C
}
stage('Подготовка') {
parallel {
stage('Подготовка 1C базы') {
agent {
label agent1C
}
stages {
stage('Подготовка базы') {
steps {
printLocation()
@ -56,42 +56,57 @@ void call() {
}
}
stage('Проверка качества') {
parallel {
stage('EDT контроль') {
agent {
label 'edt'
}
steps {
edtValidate config
}
}
stage('Синтаксический контроль') {
steps {
syntaxCheck config
}
}
stage('Дымовые тесты') {
steps {
smoke config
}
}
}
}
stage('Трансформация результатов') {
stage('Трансформация в формат EDT') {
agent {
label 'oscript'
label 'edt'
}
steps {
transform config
edtTransform config
}
}
}
}
stage('Проверка качества') {
parallel {
stage('EDT контроль') {
agent {
label 'edt'
}
steps {
edtValidate config
}
}
stage('Синтаксический контроль') {
agent {
label agent1C
}
steps {
syntaxCheck config
}
}
stage('Дымовые тесты') {
agent {
label agent1C
}
steps {
smoke config
}
}
}
}
stage('Трансформация результатов') {
agent {
label 'oscript'
}
steps {
transform config
}
}
stage('SonarQube') {
agent {
label 'sonar'