use of org.jenkins.tools.test.model.PluginCompatTesterConfig in project plugin-compat-tester by jenkinsci.
the class PluginCompatTesterCli method main.
public static void main(String[] args) throws IOException, PlexusContainerException, MavenEmbedderException {
CliOptions options = new CliOptions();
JCommander jcommander = null;
try {
jcommander = new JCommander(options, args);
} catch (ParameterException e) {
System.err.println(e.getMessage());
if (jcommander == null) {
jcommander = new JCommander(options);
}
jcommander.usage();
System.exit(1);
}
if (options.isPrintHelp()) {
jcommander.usage();
System.exit(0);
}
options.getWorkDirectory().mkdirs();
File reportFile = null;
if (!"NOREPORT".equals(options.getReportFile().getName())) {
reportFile = options.getReportFile();
}
if (reportFile != null) {
// Check the format requirement
File parentFile = reportFile.getParentFile();
if (parentFile == null) {
throw new IllegalArgumentException("The -reportFile value '" + reportFile + "' does not have a directory specification. " + "A path should be something like 'out/pct-report.xml'");
}
}
String updateCenterUrl = options.getUpdateCenterUrl();
String parentCoordinates = options.getParentCoord();
File war = options.getWar();
if (war != null) {
if (updateCenterUrl != null || parentCoordinates != null) {
throw new IllegalStateException("Cannot specify -war together with either -updateCenterUrl or -parentCoordinates");
}
}
// We may need this data even in the -war mode
if (updateCenterUrl == null) {
updateCenterUrl = PluginCompatTesterConfig.DEFAULT_UPDATE_CENTER_URL;
}
if (parentCoordinates == null) {
parentCoordinates = PluginCompatTesterConfig.DEFAULT_PARENT_GAV;
}
PluginCompatTesterConfig config = new PluginCompatTesterConfig(updateCenterUrl, parentCoordinates, options.getWorkDirectory(), reportFile, options.getM2SettingsFile());
config.setWar(war);
config.setExternalMaven(options.getExternalMaven());
if (options.getIncludePlugins() != null && !options.getIncludePlugins().isEmpty()) {
config.setIncludePlugins(Arrays.asList(options.getIncludePlugins().toLowerCase().split(",")));
}
if (options.getExcludePlugins() != null && !options.getExcludePlugins().isEmpty()) {
config.setExcludePlugins(Arrays.asList(options.getExcludePlugins().toLowerCase().split(",")));
}
if (options.getSkipTestCache() != null) {
config.setSkipTestCache(Boolean.valueOf(options.getSkipTestCache()).booleanValue());
}
if (options.getTestCacheTimeout() != null) {
config.setTestCacheTimeout(options.getTestCacheTimeout().longValue());
}
if (options.getCacheThresholdStatus() != null) {
config.setCacheThresholStatus(TestStatus.valueOf(options.getCacheThresholdStatus()));
}
if (options.getGaeBaseUrl() != null) {
config.setGaeBaseUrl(options.getGaeBaseUrl());
}
if (options.getGaeSecurityToken() != null) {
config.setGaeSecurityToken(options.getGaeSecurityToken());
}
if (options.getHookPrefixes() != null && !options.getHookPrefixes().isEmpty()) {
config.setHookPrefixes(Arrays.asList(options.getHookPrefixes().split(",")));
}
if (options.getLocalCheckoutDir() != null && !options.getLocalCheckoutDir().isEmpty()) {
config.setLocalCheckoutDir(options.getLocalCheckoutDir());
}
PluginCompatTester tester = new PluginCompatTester(config);
tester.testPlugins();
}
use of org.jenkins.tools.test.model.PluginCompatTesterConfig in project plugin-compat-tester by jenkinsci.
the class PluginCompatTesterTest method testWithUrl.
@Test
public void testWithUrl() throws Throwable {
List<String> includedPlugins = new ArrayList<String>() {
{
/*add("scm-sync-configuration");*/
add("accurev");
/*add("active-directory"); add("analysis-collector");*/
}
};
PluginCompatTesterConfig config = new PluginCompatTesterConfig(testFolder.getRoot(), new File("../reports/PluginCompatReport.xml"), new ClassPathResource("m2-settings.xml").getFile());
config.setIncludePlugins(includedPlugins);
config.setSkipTestCache(true);
config.setCacheThresholStatus(TestStatus.TEST_FAILURES);
config.setTestCacheTimeout(345600000);
config.setParentVersion("1.410");
config.setGenerateHtmlReport(true);
PluginCompatTester tester = new PluginCompatTester(config);
tester.testPlugins();
}
use of org.jenkins.tools.test.model.PluginCompatTesterConfig in project plugin-compat-tester by jenkinsci.
the class ExampleMultiParent method action.
/*
* No check implementation is required because transformedPlugins
* returns your specific list.
*/
/**
* Point to the shared location. Check if this needs to be downloaded.
*/
public Map<String, Object> action(Map<String, Object> moreInfo) throws Exception {
PluginCompatTesterConfig config = (PluginCompatTesterConfig) moreInfo.get("config");
Plugin currentPlugin = (Plugin) moreInfo.get("plugin");
// Determine if we need to run the download; only run for first identified plugin in the series
if (firstRun) {
System.out.println("Preparing for Multimodule checkout.");
// Checkout to the parent directory. All other processes will be on the child directory
File parentPath = new File(config.workDirectory.getAbsolutePath() + "/" + parentName);
System.out.println("Checking out from SCM connection URL : " + parentUrl + " (" + parentName + "-" + currentPlugin.version + ")");
ScmManager scmManager = SCMManagerFactory.getInstance().createScmManager();
ScmRepository repository = scmManager.makeScmRepository(parentUrl);
CheckOutScmResult result = scmManager.checkOut(repository, new ScmFileSet(parentPath), new ScmTag(parentName + "-" + currentPlugin.version));
if (!result.isSuccess()) {
throw new RuntimeException(result.getProviderMessage() + "||" + result.getCommandOutput());
}
}
// Checkout already happened, don't run through again
moreInfo.put("runCheckout", false);
firstRun = false;
// Change the "download"" directory; after download, it's simply used for reference
File childPath = new File(config.workDirectory.getAbsolutePath() + "/" + parentName + "/" + currentPlugin.name);
moreInfo.put("checkoutDir", childPath);
return moreInfo;
}
use of org.jenkins.tools.test.model.PluginCompatTesterConfig in project plugin-compat-tester by jenkinsci.
the class MultiParentCompileHook method getMavenConfig.
private MavenRunner.Config getMavenConfig(PluginCompatTesterConfig config) throws IOException {
MavenRunner.Config mconfig = new MavenRunner.Config();
mconfig.userSettingsFile = config.getM2SettingsFile();
// TODO REMOVE
mconfig.userProperties.put("failIfNoTests", "false");
mconfig.userProperties.put("argLine", "-XX:MaxPermSize=128m");
String mavenPropertiesFilePath = config.getMavenPropertiesFile();
if (StringUtils.isNotBlank(mavenPropertiesFilePath)) {
File file = new File(mavenPropertiesFilePath);
if (file.exists()) {
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(file);
Properties properties = new Properties();
properties.load(fileInputStream);
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
mconfig.userProperties.put((String) entry.getKey(), (String) entry.getValue());
}
} finally {
IOUtils.closeQuietly(fileInputStream);
}
} else {
System.out.println("File " + mavenPropertiesFilePath + " not exists");
}
}
return mconfig;
}
use of org.jenkins.tools.test.model.PluginCompatTesterConfig in project plugin-compat-tester by jenkinsci.
the class MultiParentCompileHook method action.
@Override
public Map<String, Object> action(Map<String, Object> moreInfo) throws Exception {
try {
System.out.println("Executing multi-parent compile hook");
PluginCompatTesterConfig config = (PluginCompatTesterConfig) moreInfo.get("config");
MavenCoordinates core = (MavenCoordinates) moreInfo.get("core");
runner = config.getExternalMaven() == null ? new InternalMavenRunner() : new ExternalMavenRunner(config.getExternalMaven());
mavenConfig = getMavenConfig(config);
File pluginDir = (File) moreInfo.get("pluginDir");
System.out.println("Plugin dir is " + pluginDir);
if (config.getLocalCheckoutDir() != null) {
Path pluginSourcesDir = config.getLocalCheckoutDir().toPath();
boolean isMultipleLocalPlugins = config.getIncludePlugins() != null && config.getIncludePlugins().size() > 1;
// If not it must be located on the parent of the localCheckoutDir
if (!isMultipleLocalPlugins) {
pluginSourcesDir = pluginSourcesDir.getParent();
}
// Copy the file if it exists
Files.walk(pluginSourcesDir, 1).filter(this::isEslintFile).forEach(eslintrc -> copy(eslintrc, pluginDir));
}
// We need to compile before generating effective pom overriding jenkins.version
// only if the plugin is not already compiled
boolean ranCompile = moreInfo.containsKey(OVERRIDE_DEFAULT_COMPILE) ? (boolean) moreInfo.get(OVERRIDE_DEFAULT_COMPILE) : false;
if (!ranCompile) {
compile(mavenConfig, pluginDir);
moreInfo.put(OVERRIDE_DEFAULT_COMPILE, true);
}
System.out.println("Executed multi-parent compile hook");
return moreInfo;
// Exceptions get swallowed, so we print to console here and rethrow again
} catch (Exception e) {
System.out.println("Exception executing hook");
System.out.println(e);
throw e;
}
}
Aggregations