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

Abstracted descriptor matching. #897

Closed
wants to merge 5 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ public StaticAnalysisLabelProvider create(final String id) {
* provider is returned.
*/
public StaticAnalysisLabelProvider create(final String id, @CheckForNull final String name) {
List<ToolDescriptor> extensions = jenkins.getDescriptorsFor(Tool.class);
for (ToolDescriptor descriptor : extensions) {
if (descriptor.getId().equals(id)) {
return createNamedLabelProvider(descriptor.getLabelProvider(), name);
}
}

List<StaticAnalysisToolFactory> factories = jenkins.getExtensionsFor(StaticAnalysisToolFactory.class);
for (StaticAnalysisToolFactory factory : factories) {
Optional<StaticAnalysisLabelProvider> labelProvider = factory.getLabelProvider(id);
Expand All @@ -73,6 +66,13 @@ public StaticAnalysisLabelProvider create(final String id, @CheckForNull final S
}
}

DescriptorExtensionList<Tool, ToolDescriptor> extensions = jenkins.getDescriptorsFor(Tool.class);
for (ToolDescriptor descriptor : extensions) {
if (descriptor.describes(id)) {
return createNamedLabelProvider(descriptor.getLabelProvider(), name);
}
}

return new StaticAnalysisLabelProvider(id, name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,5 +276,17 @@ public String getUrl() {
public boolean isPostProcessingEnabled() {
return true;
}

/**
* Returns whether the descriptor describes a tool with a certain id specified as argument.
* By default if the ID of the tool start with the descriptor ID the descriptor describes the tool.
*
* @param id
* the ID of the tool
* @return {@code true} if the descriptor describes the tool with a certain ID, {@code false} otherwise
*/
public boolean describes(final String id) {
return id.startsWith(getId());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,21 @@ public void showPreventXxeSecurity656() {
}

/**
<<<<<<< HEAD
* Verifies that a tool that have an ID that starts with the descriptor ID keeps the correct LabelProvider.
*/
@Test
public void keepLabelProviderUsingDifferentsIds() {
WorkflowJob job = createPipelineWithWorkspaceFiles("javadoc.txt");
job.setDefinition(asStage(
"recordIssues tool: javaDoc(pattern:'**/*issues.txt', reportEncoding:'UTF-8')",
"recordIssues tool: javaDoc(id:'javadoc-warnings-1', pattern:'**/*issues.txt', reportEncoding:'UTF-8')"
));
Run<?, ?> run = buildSuccessfully(job);
List<ResultAction> actions = run.getActions(ResultAction.class);
assertThat(actions.size()).isEqualTo(2);
assertThat(actions.get(0).getLabelProvider()).hasName(actions.get(1).getLabelProvider().getName());
=======
* Verifies that the json model for the pull request monitoring portlet is generated properly.
*/
@Test
Expand All @@ -1100,6 +1115,7 @@ public void shouldGenerateJsonDataModel() {
assertThatJson(model).node("new").node("error").isEqualTo(0);

assertThat(portlet.hasQualityGate()).isFalse();
>>>>>>> jenkinsci/master
}

private void write(final String adaptedOobFileContent) {
Expand Down