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 Swarm Plugin support to PCT #188

Merged
merged 2 commits into from
Sep 12, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void validate(Map<String, Object> toCheck) throws Exception {
@Override
public boolean check(Map<String, Object> info) throws Exception {
return BlueOceanHook.isBOPlugin(info) || DeclarativePipelineHook.isDPPlugin(info) || StructsHook.isStructsPlugin(info) ||
ConfigurationAsCodeHook.isCascPlugin(info) || PipelineRestApiHook.isPipelineStageViewPlugin(info);
SwarmHook.isSwarmPlugin(info) || ConfigurationAsCodeHook.isCascPlugin(info) || PipelineRestApiHook.isPipelineStageViewPlugin(info);
Copy link
Member

Choose a reason for hiding this comment

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

We should finally rewrite the hook engine at some point to an extension-alike approach.
This line makes me cry :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, this would be a good area for future improvement.

}

private boolean isEslintFile(Path file) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package org.jenkins.tools.test.hook;

import hudson.model.UpdateSite;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jenkins.tools.test.model.PomData;

public class SwarmHook extends AbstractMultiParentHook {

private static final Logger LOGGER = Logger.getLogger(SwarmHook.class.getName());

@Override
protected String getParentFolder() {
return "swarm";
}

@Override
protected String getParentUrl() {
return "scm:git:git://github.com/jenkinsci/swarm-plugin.git";
}

@Override
protected String getParentProjectName() {
return "swarm-plugin";
}

@Override
protected String getPluginFolderName(UpdateSite.Plugin currentPlugin) {
return "plugin";
}

@Override
public boolean check(Map<String, Object> info) throws Exception {
return isSwarmPlugin(info);
}

public static boolean isSwarmPlugin(Map<String, Object> moreInfo) {
PomData data = (PomData) moreInfo.get("pomData");
return isSwarmPlugin(data);
}

public static boolean isSwarmPlugin(PomData data) {
if (data.parent != null) {
// Non-incrementals
return data.parent.artifactId.equalsIgnoreCase("swarm-plugin");
} else if (!"swarm".equalsIgnoreCase(data.artifactId)) {
return false;
} else {
LOGGER.log(
Level.WARNING,
"Swarm Plugin may have been incrementalified. "
+ "See JENKINS-55169 and linked tickets. Will guess by the packaging: {0}",
data.getPackaging());
return "hpi".equalsIgnoreCase(data.getPackaging());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public boolean check(Map<String, Object> info) {
boolean isDeclarativePipeline = DeclarativePipelineHook.isDPPlugin(pomData);
boolean isCasC = ConfigurationAsCodeHook.isCascPlugin(pomData);
boolean isPipelineStageViewPlugin = PipelineRestApiHook.isPipelineStageViewPlugin(pomData);
boolean isSwarm = SwarmHook.isSwarmPlugin(pomData);
boolean pluginPOM = pomData.isPluginPOM();
if (parent != null) {
isCB = parent.matches("com.cloudbees.jenkins.plugins", "jenkins-plugins") ||
Expand All @@ -58,7 +59,7 @@ public boolean check(Map<String, Object> info) {
boolean coreRequiresNewParentPOM = coreCoordinates.compareVersionTo(CORE_NEW_PARENT_POM) >= 0;
boolean coreRequiresPluginOver233 = coreCoordinates.compareVersionTo(CORE_WITHOUT_WAR_FOR_TEST) >= 0;

if (isDeclarativePipeline || isBO || isCB || isStructs || isCasC || isPipelineStageViewPlugin || (pluginPOM && parentV2)) {
if (isDeclarativePipeline || isBO || isCB || isStructs || isCasC || isPipelineStageViewPlugin || isSwarm || (pluginPOM && parentV2)) {
Copy link
Member

Choose a reason for hiding this comment

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

Same here

List<String> argsToMod = (List<String>)info.get("args");
argsToMod.add("-Djenkins.version=" + coreCoordinates.version);
// There are rules that avoid dependencies on a higher java level. Depending on the baselines and target cores
Expand Down
4 changes: 4 additions & 0 deletions src/it/war-with-plugins-test/packager-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ plugins:
artifactId: "structs"
source:
version: 1.18
- groupId: "org.jenkins-ci.plugins"
artifactId: "swarm"
source:
version: 3.17
- groupId: "org.jenkins-ci.plugins"
artifactId: "matrix-project"
source:
Expand Down