You've already forked jenkins-lib
mirror of
https://github.com/firstBitMarksistskaya/jenkins-lib.git
synced 2025-08-25 20:09:25 +02:00
add lockable resources in bdd
This commit is contained in:
@@ -250,6 +250,10 @@
|
||||
"type" : "string",
|
||||
"description" : "Путь к исполняемому файлу dbgs.\n По умолчанию равен /opt/1cv8/current/dbgs.\n "
|
||||
},
|
||||
"dbgsPort" : {
|
||||
"type" : "integer",
|
||||
"description" : "Порт сервера отладки.\n По умолчанию равен 1550.\n "
|
||||
},
|
||||
"coverage41CPath" : {
|
||||
"type" : "string",
|
||||
"description" : "Путь к исполняемому файлу Coverage41C\n По умолчанию равен Coverage41C.\n "
|
||||
|
@@ -66,6 +66,8 @@ interface IStepExecutor {
|
||||
|
||||
def withEnv(List<String> strings, Closure body)
|
||||
|
||||
def lock(String label, int quantity, String resource, Closure<Object> objectClosure)
|
||||
|
||||
def archiveArtifacts(String path)
|
||||
|
||||
def stash(String name, String includes)
|
||||
|
@@ -149,6 +149,13 @@ class StepExecutor implements IStepExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
def lock(String label, int quantity, String resource, Closure body) {
|
||||
steps.lock(label, quantity, resource) {
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
def archiveArtifacts(String path) {
|
||||
steps.archiveArtifacts path
|
||||
|
@@ -14,23 +14,23 @@ import static java.util.Collections.emptySet
|
||||
class ConfigurationReader implements Serializable {
|
||||
|
||||
private static ObjectMapper mapper
|
||||
private static BeanUtilsBean beanUtilsBean;
|
||||
private static BeanUtilsBean beanUtilsBean
|
||||
|
||||
static {
|
||||
mapper = new ObjectMapper()
|
||||
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
|
||||
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true)
|
||||
|
||||
beanUtilsBean = new BeanUtilsBean(new ConvertUtilsBean() {
|
||||
@Override
|
||||
@NonCPS
|
||||
Object convert(String value, Class clazz) {
|
||||
if (clazz.isEnum()) {
|
||||
return Enum.valueOf(clazz, value);
|
||||
return Enum.valueOf(clazz, value)
|
||||
} else {
|
||||
return super.convert(value, clazz);
|
||||
return super.convert(value, clazz)
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
private static final String DEFAULT_CONFIGURATION_RESOURCE = 'globalConfiguration.json'
|
||||
@@ -49,7 +49,7 @@ class ConfigurationReader implements Serializable {
|
||||
def globalConfiguration = create()
|
||||
def jobConfiguration = mapper.readValue(config, JobConfiguration.class)
|
||||
|
||||
return mergeConfigurations(globalConfiguration, jobConfiguration);
|
||||
return mergeConfigurations(globalConfiguration, jobConfiguration)
|
||||
}
|
||||
|
||||
private static JobConfiguration mergeConfigurations(
|
||||
@@ -82,11 +82,10 @@ class ConfigurationReader implements Serializable {
|
||||
mergeObjects(baseConfiguration, configurationToMerge, nonMergeableSettings)
|
||||
mergeInitInfoBaseOptions(baseConfiguration.initInfoBaseOptions, configurationToMerge.initInfoBaseOptions)
|
||||
mergeBddOptions(baseConfiguration.bddOptions, configurationToMerge.bddOptions)
|
||||
mergeCoverageOptions(baseConfiguration.coverageOptions, configurationToMerge.coverageOptions)
|
||||
mergeSyntaxCheckOptions(baseConfiguration.syntaxCheckOptions, configurationToMerge.syntaxCheckOptions)
|
||||
mergeNotificationsOptions(baseConfiguration.notificationsOptions, configurationToMerge.notificationsOptions)
|
||||
|
||||
return baseConfiguration;
|
||||
return baseConfiguration
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
@@ -97,7 +96,7 @@ class ConfigurationReader implements Serializable {
|
||||
.filter({ e -> e.getKey() != "metaClass" })
|
||||
.filter({ e -> !nonMergeableSettings.contains(e.getKey()) })
|
||||
.forEach { e ->
|
||||
beanUtilsBean.setProperty(baseObject, e.getKey(), e.getValue());
|
||||
beanUtilsBean.setProperty(baseObject, e.getKey(), e.getValue())
|
||||
}
|
||||
|
||||
nonMergeableSettings.forEach({ key ->
|
||||
@@ -149,22 +148,6 @@ class ConfigurationReader implements Serializable {
|
||||
baseObject.vrunnerSteps = objectToMerge.vrunnerSteps.clone()
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
private static void mergeCoverageOptions(CoverageOptions baseObject, CoverageOptions objectToMerge) {
|
||||
|
||||
if (objectToMerge == null) {
|
||||
return
|
||||
}
|
||||
|
||||
if (objectToMerge.dbgsPath != null) {
|
||||
baseObject.dbgsPath = objectToMerge.dbgsPath
|
||||
}
|
||||
|
||||
if (objectToMerge.coverage41CPath != null) {
|
||||
baseObject.coverage41CPath = objectToMerge.coverage41CPath
|
||||
}
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
private static void mergeSyntaxCheckOptions(SyntaxCheckOptions baseObject, SyntaxCheckOptions objectToMerge) {
|
||||
if (objectToMerge == null || objectToMerge.checkModes == null) {
|
||||
|
@@ -12,6 +12,11 @@ class CoverageOptions implements Serializable {
|
||||
''')
|
||||
String dbgsPath
|
||||
|
||||
@JsonPropertyDescription('''Порт сервера отладки.
|
||||
По умолчанию равен 1550.
|
||||
''')
|
||||
int dbgsPort = 1550
|
||||
|
||||
@JsonPropertyDescription('''Путь к исполняемому файлу Coverage41C
|
||||
По умолчанию равен Coverage41C.
|
||||
''')
|
||||
@@ -22,8 +27,9 @@ class CoverageOptions implements Serializable {
|
||||
String toString() {
|
||||
return "coverageOptions{" +
|
||||
"dbgsPath=" + dbgsPath +
|
||||
"dbgsPort=" + dbgsPort +
|
||||
", coverage41CPath=" + coverage41CPath +
|
||||
'}';
|
||||
'}'
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ import ru.pulsar.jenkins.library.configuration.JobConfiguration
|
||||
import ru.pulsar.jenkins.library.ioc.ContextRegistry
|
||||
import ru.pulsar.jenkins.library.utils.FileUtils
|
||||
import ru.pulsar.jenkins.library.utils.Logger
|
||||
import ru.pulsar.jenkins.library.utils.PortPicker
|
||||
import org.apache.commons.lang.RandomStringUtils
|
||||
import ru.pulsar.jenkins.library.utils.VRunner
|
||||
|
||||
class Bdd implements Serializable {
|
||||
@@ -27,7 +27,7 @@ class Bdd implements Serializable {
|
||||
}
|
||||
|
||||
def options = config.bddOptions
|
||||
def env = steps.env();
|
||||
def env = steps.env()
|
||||
def srcDir = config.srcDir
|
||||
def workspaceDir = FileUtils.getFilePath("$env.WORKSPACE")
|
||||
|
||||
@@ -37,15 +37,21 @@ class Bdd implements Serializable {
|
||||
steps.createDir('build/out')
|
||||
List<Integer> returnStatuses = []
|
||||
|
||||
def coverageOpts = config.coverageOptions;
|
||||
def port = PortPicker.getPort();
|
||||
port = 1550;
|
||||
def coverageOpts = config.coverageOptions
|
||||
def port = coverageOpts.dbgsPort
|
||||
def lockable_resource = RandomStringUtils.random(9, true, false)
|
||||
|
||||
if (options.coverage) {
|
||||
steps.start("${coverageOpts.dbgsPath} --addr=127.0.0.1 --port=$port")
|
||||
steps.start("${coverageOpts.coverage41CPath} start -i DefAlias -u http://127.0.0.1:$port -P $workspaceDir -s $srcDir -o build/out/bdd-coverage.xml")
|
||||
steps.cmd("${coverageOpts.coverage41CPath} check -i DefAlias -u http://127.0.0.1:$port")
|
||||
lockable_resource = "${env.NODE_NAME}_$port"
|
||||
}
|
||||
|
||||
steps.lock("label", 1, lockable_resource) {
|
||||
if (options.coverage) {
|
||||
steps.start("${coverageOpts.dbgsPath} --addr=127.0.0.1 --port=$port")
|
||||
steps.start("${coverageOpts.coverage41CPath} start -i DefAlias -u http://127.0.0.1:$port -P $workspaceDir -s $srcDir -o build/out/bdd-coverage.xml")
|
||||
steps.cmd("${coverageOpts.coverage41CPath} check -i DefAlias -u http://127.0.0.1:$port")
|
||||
}
|
||||
|
||||
config.bddOptions.vrunnerSteps.each {
|
||||
Logger.println("Шаг запуска сценариев командой ${it}")
|
||||
String vrunnerPath = VRunner.getVRunnerPath()
|
||||
@@ -61,8 +67,12 @@ class Bdd implements Serializable {
|
||||
Logger.println("Тестирование сценариев завершилось успешно")
|
||||
}
|
||||
|
||||
if (options.coverage) {
|
||||
steps.cmd("${coverageOpts.coverage41CPath} stop -i DefAlias -u http://127.0.0.1:$port")
|
||||
if (options.coverage) {
|
||||
steps.cmd("${coverageOpts.coverage41CPath} stop -i DefAlias -u http://127.0.0.1:$port")
|
||||
}
|
||||
|
||||
return 0
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -75,6 +75,7 @@ class jobConfigurationTest {
|
||||
rule.assertLogContains("sonarScannerToolName='sonar-scanner'", run)
|
||||
rule.assertLogContains("initMethod=FROM_SOURCE", run)
|
||||
rule.assertLogContains("dbgsPath=C:\\Program files\\1cv8\\8.3.12.1500\\bin\\dbgs.exe", run)
|
||||
rule.assertLogContains("dbgsPort=4543", run)
|
||||
rule.assertLogContains("coverage41CPath=C:\\coverage\\Coverage41C.exe", run)
|
||||
}
|
||||
}
|
@@ -13,6 +13,7 @@
|
||||
},
|
||||
"coverage": {
|
||||
"dbgsPath": "C:\\\\Program files\\\\1cv8\\\\8.3.12.1500\\\\bin\\\\dbgs.exe",
|
||||
"dbgsPort": 4543,
|
||||
"coverage41CPath": "C:\\\\coverage\\\\Coverage41C.exe"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user