Skip to content

Commit

Permalink
nemerosa/ontrack#1343 Support for auto-versioning additional paths
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Sep 6, 2024
1 parent 29126f1 commit a57a28a
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ class AutoVersioningContext {
}
}

List<AutoVersioningDependencyPath> additionalPaths = null
def additionalPathsArray = params.additionalPaths
if (additionalPathsArray) {
additionalPaths = additionalPathsArray.collect {
new AutoVersioningDependencyPath(
it.path as String,
it.regex as String,
it.property as String,
it.propertyRegex as String,
it.propertyType as String,
it.versionSource as String,
)
}
}

String postProcessing = params.postProcessing
def postProcessingConfig = params.postProcessingConfig as Map<String, ?> ?: [:]

Expand All @@ -131,6 +146,7 @@ class AutoVersioningContext {
prBodyTemplateFormat,
reviewers,
notifications,
additionalPaths,
)

// Adding this configuration to the list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ class AutoVersioningDependency {
private final String prBodyTemplateFormat
private final List<String> reviewers
private final List<AutoVersioningNotification> notifications
private final List<AutoVersioningDependencyPath> additionalPaths

AutoVersioningDependency(String sourceProject, String sourceBranch, String sourcePromotion, String targetPath, String targetRegex, String targetProperty, String targetPropertyRegex, String targetPropertyType, Boolean autoApproval, String upgradeBranchPattern, String validationStamp, String postProcessing, Map<String, ?> postProcessingConfig, String autoApprovalMode, String qualifier, String versionSource, String prTitleTemplate, String prBodyTemplate, String prBodyTemplateFormat, List<String> reviewers, List<AutoVersioningNotification> notifications) {
AutoVersioningDependency(String sourceProject, String sourceBranch, String sourcePromotion, String targetPath, String targetRegex, String targetProperty, String targetPropertyRegex, String targetPropertyType, Boolean autoApproval, String upgradeBranchPattern, String validationStamp, String postProcessing, Map<String, ?> postProcessingConfig, String autoApprovalMode, String qualifier, String versionSource, String prTitleTemplate, String prBodyTemplate, String prBodyTemplateFormat, List<String> reviewers, List<AutoVersioningNotification> notifications, List<AutoVersioningDependencyPath> additionalPaths) {
this.sourceProject = sourceProject
this.sourceBranch = sourceBranch
this.sourcePromotion = sourcePromotion
Expand All @@ -46,6 +47,7 @@ class AutoVersioningDependency {
this.prBodyTemplateFormat = prBodyTemplateFormat
this.reviewers = reviewers
this.notifications = notifications
this.additionalPaths = additionalPaths
}

String getSourceProject() {
Expand Down Expand Up @@ -132,6 +134,10 @@ class AutoVersioningDependency {
return notifications
}

List<AutoVersioningDependencyPath> getAdditionalPaths() {
return additionalPaths
}

Map<String, ?> toMap() {
return [
sourceProject : sourceProject,
Expand All @@ -155,6 +161,7 @@ class AutoVersioningDependency {
prBodyTemplateFormat: prBodyTemplateFormat,
reviewers : reviewers,
notifications : notifications?.collect { it.toMap() },
additionalPaths : additionalPaths?.collect { it.toMap() },
]
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package net.nemerosa.ontrack.jenkins.pipeline.autoversioning

class AutoVersioningDependencyPath {

private final String path
private final String regex
private final String property
private final String propertyRegex
private final String propertyType
private final String versionSource

AutoVersioningDependencyPath(String path, String regex, String property, String propertyRegex, String propertyType, String versionSource) {
this.path = path
this.regex = regex
this.property = property
this.propertyRegex = propertyRegex
this.propertyType = propertyType
this.versionSource = versionSource
}

String getPath() {
return path
}

String getRegex() {
return regex
}

String getProperty() {
return property
}

String getPropertyRegex() {
return propertyRegex
}

String getPropertyType() {
return propertyType
}

String getVersionSource() {
return versionSource
}

Map<String, ?> toMap() {
return [
path : path,
regex : regex,
property : property,
propertyRegex: propertyRegex,
propertyType : propertyType,
versionSource: versionSource,
]
}
}

0 comments on commit a57a28a

Please sign in to comment.