Search in sources :

Example 1 with MavenCoordinates

use of org.jenkins.tools.test.model.MavenCoordinates in project plugin-compat-tester by jenkinsci.

the class TransformPom method action.

public Map<String, Object> action(Map<String, Object> moreInfo) throws Exception {
    MavenCoordinates coreCoordinates = (MavenCoordinates) moreInfo.get("coreCoordinates");
    final String pluginsParentVersion = (String) moreInfo.get(NEW_PLUGINS_PARENT_VERSION_KEY);
    if (pluginsParentVersion != null) {
        coreCoordinates = new MavenCoordinates(coreCoordinates.groupId, coreCoordinates.artifactId, pluginsParentVersion);
    }
    ((MavenPom) moreInfo.get("pom")).transformPom(coreCoordinates);
    return moreInfo;
}
Also used : MavenCoordinates(org.jenkins.tools.test.model.MavenCoordinates) MavenPom(org.jenkins.tools.test.model.MavenPom)

Example 2 with MavenCoordinates

use of org.jenkins.tools.test.model.MavenCoordinates in project plugin-compat-tester by jenkinsci.

the class TransformPom method check.

/**
 * Check if the pom should be transformed for the given plugin.
 */
public boolean check(Map<String, Object> info) {
    boolean mustTransformPom = false;
    // TODO future versions of DEFAULT_PARENT_GROUP/ARTIFACT may be able to use this as well
    PomData pomData = (PomData) info.get("pomData");
    MavenCoordinates parent = pomData.parent;
    MavenCoordinates coreCoordinates = (MavenCoordinates) info.get("coreCoordinates");
    boolean isDeclarativePipeline = parent.matches("org.jenkinsci.plugins", "pipeline-model-parent");
    boolean isCB = parent.matches("com.cloudbees.jenkins.plugins", "jenkins-plugins") || // TODO ought to analyze the chain of parent POMs, which would lead to com.cloudbees.jenkins.plugins:jenkins-plugins in this case:
    parent.matches("com.cloudbees.operations-center.common", "operations-center-parent") || parent.matches("com.cloudbees.operations-center.client", "operations-center-parent-client");
    boolean isBO = parent.matches("io.jenkins.blueocean", "blueocean-parent");
    boolean isStructs = parent.matches("org.jenkins-ci.plugins", "structs-parent");
    boolean pluginPOM = parent.matches("org.jenkins-ci.plugins", "plugin");
    boolean parentV2 = parent.compareVersionTo("2.0") >= 0;
    boolean parentUnder233 = parentV2 && parent.compareVersionTo(PLUGINS_PARENT_POM_FOR_CORE_WITHOUT_WAR_TEST) < 0;
    boolean coreRequiresNewParentPOM = coreCoordinates.compareVersionTo(CORE_NEW_PARENT_POM) >= 0;
    boolean coreRequiresPluginOver233 = coreCoordinates.compareVersionTo(CORE_WITHOUT_WAR_FOR_TEST) >= 0;
    if (isDeclarativePipeline || isBO || isCB || isStructs || (pluginPOM && parentV2)) {
        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
        // the plugin may be Java 6 and the dependencies bring Java 7
        argsToMod.add("-Denforcer.skip=true");
        info.put("args", argsToMod);
        if (coreRequiresPluginOver233 && pluginPOM && parentUnder233) {
            info.put(NEW_PLUGINS_PARENT_VERSION_KEY, PLUGINS_PARENT_POM_FOR_CORE_WITHOUT_WAR_TEST);
            mustTransformPom = true;
        }
    } else if (coreRequiresNewParentPOM && pluginPOM && !parentV2) {
        throw new RuntimeException("New parent POM required for core >= 1.646");
    } else {
        mustTransformPom = true;
    }
    return mustTransformPom;
}
Also used : MavenCoordinates(org.jenkins.tools.test.model.MavenCoordinates) PomData(org.jenkins.tools.test.model.PomData) List(java.util.List)

Example 3 with MavenCoordinates

use of org.jenkins.tools.test.model.MavenCoordinates in project plugin-compat-tester by jenkinsci.

the class PluginCompatTester method coreVersionFromWAR.

private SortedSet<MavenCoordinates> coreVersionFromWAR(UpdateSite.Data data) {
    SortedSet<MavenCoordinates> result = new TreeSet<MavenCoordinates>();
    result.add(new MavenCoordinates(PluginCompatTesterConfig.DEFAULT_PARENT_GROUP, PluginCompatTesterConfig.DEFAULT_PARENT_ARTIFACT, data.core.version));
    return result;
}
Also used : MavenCoordinates(org.jenkins.tools.test.model.MavenCoordinates) TreeSet(java.util.TreeSet)

Example 4 with MavenCoordinates

use of org.jenkins.tools.test.model.MavenCoordinates in project plugin-compat-tester by jenkinsci.

the class PluginCompatTester method generateCoreCoordinatesToTest.

private SortedSet<MavenCoordinates> generateCoreCoordinatesToTest(UpdateSite.Data data, PluginCompatReport previousReport) {
    SortedSet<MavenCoordinates> coreCoordinatesToTest = null;
    // against 1 core coordinate
    if (config.getParentGroupId() != null && config.getParentArtifactId() != null) {
        coreCoordinatesToTest = new TreeSet<MavenCoordinates>();
        // If coreVersion is not provided in PluginCompatTesterConfig, let's use latest core
        // version used in update center
        String coreVersion = config.getParentVersion() == null ? data.core.version : config.getParentVersion();
        MavenCoordinates coreArtifact = new MavenCoordinates(config.getParentGroupId(), config.getParentArtifactId(), coreVersion);
        coreCoordinatesToTest.add(coreArtifact);
    // If parent groupId/artifactId are null, we'll test against every already recorded
    // cores
    } else if (config.getParentGroupId() == null && config.getParentArtifactId() == null) {
        coreCoordinatesToTest = previousReport.getTestedCoreCoordinates();
    } else {
        throw new IllegalStateException("config.parentGroupId and config.parentArtifactId should either be both null or both filled\n" + "config.parentGroupId=" + String.valueOf(config.getParentGroupId()) + ", config.parentArtifactId=" + String.valueOf(config.getParentArtifactId()));
    }
    return coreCoordinatesToTest;
}
Also used : MavenCoordinates(org.jenkins.tools.test.model.MavenCoordinates)

Example 5 with MavenCoordinates

use of org.jenkins.tools.test.model.MavenCoordinates in project plugin-compat-tester by jenkinsci.

the class WritePCTResultServlet method service.

@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    // Current servlet is secured !
    SecuritySupport.ensureTokenIsValid(req);
    // Parsing request...
    String pluginName = req.getParameter("pluginName");
    String pluginVersion = req.getParameter("pluginVersion");
    String pluginUrl = req.getParameter("pluginUrl");
    TestStatus status = TestStatus.valueOf(req.getParameter("status"));
    String errorMessages = req.getParameter("errMsg");
    List<String> warningMessages = null;
    if (req.getParameterValues("warnMsgs") != null) {
        warningMessages = Arrays.asList(req.getParameterValues("warnMsgs"));
    }
    String dateTimestampStr = req.getParameter("timestamp");
    Date date = null;
    if (dateTimestampStr == null) {
        // If date is not set, use NOW
        date = new Date();
    } else {
        date = new Date(Long.valueOf(dateTimestampStr));
    }
    String buildLogPath = req.getParameter("buildLogPath");
    PluginInfos pluginInfos = new PluginInfos(pluginName, pluginVersion, pluginUrl);
    MavenCoordinates mavenCoords = MavenCoordinates.fromGAV(req.getParameter("mavenGAV"));
    PluginCompatResult result = new PluginCompatResult(mavenCoords, status, errorMessages, warningMessages, buildLogPath, date);
    // Now, persisting result data into datastore !
    Key resultKey = PluginCompatResultDAO.INSTANCE.persist(pluginInfos, result);
    String logContent = req.getParameter("logContent");
    if (logContent != null && buildLogPath != null) {
        LogsDAO.INSTANCE.persistBuildLog(buildLogPath, logContent, resultKey);
    }
    resp.getWriter().print(String.format("id=%d", resultKey.getId()));
}
Also used : TestStatus(org.jenkins.tools.test.model.TestStatus) MavenCoordinates(org.jenkins.tools.test.model.MavenCoordinates) PluginInfos(org.jenkins.tools.test.model.PluginInfos) Date(java.util.Date) PluginCompatResult(org.jenkins.tools.test.model.PluginCompatResult) Key(com.google.appengine.api.datastore.Key)

Aggregations

MavenCoordinates (org.jenkins.tools.test.model.MavenCoordinates)10 PomData (org.jenkins.tools.test.model.PomData)3 File (java.io.File)2 IOException (java.io.IOException)2 PomExecutionException (org.jenkins.tools.test.exception.PomExecutionException)2 ExternalMavenRunner (org.jenkins.tools.test.maven.ExternalMavenRunner)2 InternalMavenRunner (org.jenkins.tools.test.maven.InternalMavenRunner)2 PluginCompatResult (org.jenkins.tools.test.model.PluginCompatResult)2 PluginCompatTesterConfig (org.jenkins.tools.test.model.PluginCompatTesterConfig)2 PluginInfos (org.jenkins.tools.test.model.PluginInfos)2 TestStatus (org.jenkins.tools.test.model.TestStatus)2 Key (com.google.appengine.api.datastore.Key)1 UpdateSite (hudson.model.UpdateSite)1 Plugin (hudson.model.UpdateSite.Plugin)1 VersionNumber (hudson.util.VersionNumber)1 FileInputStream (java.io.FileInputStream)1 Writer (java.io.Writer)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1