Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all artifacts to maintainers and issue lists when wildcard is used #4108

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions permissions/plugin-aws-java-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ issues:
paths:
- "org/jenkins-ci/plugins/aws-java-sdk"
- "org/jenkins-ci/plugins/aws-java-sdk/aws-java-sdk-*"
extraNames:
- aws-java-sdk-api-gateway
- aws-java-sdk-autoscaling
- aws-java-sdk-cloudformation
- aws-java-sdk-cloudfront
- aws-java-sdk-codebuild
- aws-java-sdk-codedeploy
- aws-java-sdk-ec2
- aws-java-sdk-ecr
- aws-java-sdk-ecs
- aws-java-sdk-efs
- aws-java-sdk-elasticbeanstalk
- aws-java-sdk-elasticloadbalancingv2
- aws-java-sdk-iam
- aws-java-sdk-kinesis
- aws-java-sdk-lambda
- aws-java-sdk-logs
- aws-java-sdk-minimal
- aws-java-sdk-organizations
- aws-java-sdk-secretsmanager
- aws-java-sdk-sns
- aws-java-sdk-sqs
- aws-java-sdk-ssm
cd:
enabled: true
developers:
Expand Down
3 changes: 3 additions & 0 deletions permissions/plugin-gcp-java-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ github: &GH "jenkinsci/gcp-java-sdk-plugin"
paths:
- "io/jenkins/plugins/gcp-java-sdk"
- "io/jenkins/plugins/gcp-java-sdk-*"
extraNames:
- gcp-java-sdk-auth
- gcp-java-sdk-storage
developers:
- "aneveux"
- "@cloudbees-developers"
Expand Down
5 changes: 5 additions & 0 deletions permissions/plugin-mina-sshd-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: "mina-sshd-api"
github: &GH "jenkinsci/mina-sshd-api-plugin"
paths:
- "io/jenkins/plugins/mina-sshd-api/mina-sshd-api-*"
extraNames:
- "mina-sshd-api-common"
- "mina-sshd-api-core"
- "mina-sshd-api-scp"
- "mina-sshd-api-sftp"
cd:
enabled: true
developers:
Expand Down
3 changes: 2 additions & 1 deletion permissions/plugin-remoting-opentelemetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: "remoting-opentelemetry"
github: &GH "jenkinsci/remoting-opentelemetry-plugin"
paths:
- "io/jenkins/plugins/remoting-opentelemetry*"
- "io/jenkins/plugins/remoting-opentelemetry"
- "io/jenkins/plugins/remoting-opentelemetry-*"
developers:
- "aki7m"
- "oleg_nenashev"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,43 +173,49 @@ class ArtifactoryPermissionsUpdater {

if (definition.issues) {
if (definition.github) {
issueTrackersByPlugin.put(definition.name, definition.issues.collect { tracker ->
if (tracker.isJira() || tracker.isGitHubIssues()) {
def ret = [type: tracker.getType(), reference: tracker.getReference()]
def viewUrl = tracker.getViewUrl()
if (viewUrl) {
ret += [ viewUrl: viewUrl ]
}
def reportUrl = tracker.getReportUrl()
if (reportUrl) {
ret += [ reportUrl: reportUrl ]
ArrayList<String> names = new ArrayList(Arrays.asList(definition.getExtraNames()))
names.add(definition.name)
for (String name: names) {
issueTrackersByPlugin.put(name, definition.issues.collect { tracker ->
if (tracker.isJira() || tracker.isGitHubIssues()) {
def ret = [type: tracker.getType(), reference: tracker.getReference()]
def viewUrl = tracker.getViewUrl()
if (viewUrl) {
ret += [viewUrl: viewUrl]
}
def reportUrl = tracker.getReportUrl()
if (reportUrl) {
ret += [reportUrl: reportUrl]
}
return ret
}
return ret
}
return null
}.findAll { it != null })
return null
}.findAll { it != null })
}
} else {
throw new Exception("Issue trackers ('issues') support requires GitHub repository ('github')")
}
}

String artifactId = definition.name
for (String path : definition.paths) {
if (path.substring(path.lastIndexOf('/') + 1) != artifactId) {
String lastPathElement = path.substring(path.lastIndexOf('/') + 1)
if (lastPathElement != artifactId && !lastPathElement.contains("*")) {
// We could throw an exception here, but we actively abuse this for unusually structured components
LOGGER.log(Level.WARNING, "Unexpected path: " + path + " for artifact ID: " + artifactId)
if (lastPathElement.endsWith("-releaseblocker") || lastPathElement.endsWith("-releaseblock")) {
LOGGER.log(Level.INFO, "Release blocked for artifact ID: " + artifactId)
Comment on lines +205 to +206
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than add special handling for a weakly adhered to naming convention, if we add code for this case, it should just be a new attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #4127

} else {
LOGGER.log(Level.WARNING, "Unexpected path: " + path + " for artifact ID: " + artifactId)
}
}
String groupId = path.substring(0, path.lastIndexOf('/')).replace('/', '.')

String key = groupId + ":" + artifactId

if (maintainersByComponent.containsKey(key)) {
LOGGER.log(Level.WARNING, "Duplicate maintainers entry for component: " + key)
if (lastPathElement.contains("*")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unnecessarily complicated, because extraNames is expected to only exist with wildcard in the first place?

for (String name: definition.getExtraNames()) {
addMaintainers(maintainersByComponent, groupId + ":" + name, definition)
}
} else {
addMaintainers(maintainersByComponent, groupId + ":" + artifactId, definition)
}
// A potential issue with this implementation is that groupId changes will result in lack of maintainer information for the old groupId.
// In practice this will probably not be a problem when path changes here and subsequent release are close enough in time.
// Alternatively, always keep the old groupId around for a while.
maintainersByComponent.computeIfAbsent(key, { _ -> new ArrayList<>(Arrays.asList(definition.developers)) })
}

String fileBaseName = file.name.replaceAll('\\.ya?ml$', '')
Expand Down Expand Up @@ -358,6 +364,16 @@ class ArtifactoryPermissionsUpdater {
new File('checks-details.txt').text = details
}

private static void addMaintainers(HashMap<String, List<String>> maintainersByComponent, String key, Definition definition) {
if (maintainersByComponent.containsKey(key)) {
LOGGER.log(Level.WARNING, "Duplicate maintainers entry for component: " + key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, we have some of these in the log. Anyone want to look into this?

}
// A potential issue with this implementation is that groupId changes will result in lack of maintainer information for the old groupId.
// In practice this will probably not be a problem when path changes here and subsequent release are close enough in time.
// Alternatively, always keep the old groupId around for a while.
maintainersByComponent.computeIfAbsent(key, { _ -> new ArrayList<>(Arrays.asList(definition.developers)) })
}

/**
* Takes a directory with Artifactory API payloads and submits them to the appropriate Artifactory API,
* creating/updating the specified objects identified through the file name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public String getType() {
private String[] paths = new String[0];
private String[] developers = new String[0];
private IssueTracker[] issues = new IssueTracker[0];
private String[] extraNames = new String[0];

private String github;

Expand Down Expand Up @@ -153,6 +154,14 @@ public void setPaths(String[] paths) {
this.paths = paths.clone();
}

public void setExtraNames(String[] extraNames) {
this.extraNames = extraNames.clone();
}

public String[] getExtraNames() {
return extraNames.clone();
}

public IssueTracker[] getIssues() {
return issues.clone();
}
Expand Down