...
<dependency> <groupId>org.jenkins-ci.plugins</groupId>
<artifactId>groovy</artifactId>
<version>2.0</version>
<scope>test</scope>
</dependency>
...
// this is just using the WithPlugin annotation based on the groovy version 1.30
@WithPlugin("groovy.hpi")
@Test public void testJobWithSystemGroovy1() throws Exception {
FreeStyleProject project = j.createFreeStyleProject("SystemWithSandbox");
project.getBuildersList().add(new hudson.plugins.groovy.SystemGroovy(new StringScriptSource("println 'hi'"),null,null));
assertTrue(checker.executeCheck(project));
}
// This is just using the pom dependencies: groovy plugin version 2.0
@Test public void testJobWithSystemGroovy2() throws Exception {
FreeStyleProject project = j.createFreeStyleProject("SystemWithSandbox");
project.getBuildersList().add(new hudson.plugins.groovy.SystemGroovy(new StringScriptSource("println 'hi'"),null,null));
assertTrue(checker.executeCheck(project));
}
public boolean executeCheck(Item item) {
boolean found = false;
PluginWrapper plugin = Jenkins.getInstance().pluginManager.getPlugin("groovy");
if (plugin==null) {
LOG.log(Level.FINE, "Plugin Groovy isn't installed");
} else {
if (plugin.getVersionNumber().isNewerThan(new hudson.util.VersionNumber("1.30"))) {
....
}
For instance:
- groovy plugin version 2.0 uses the script security plugin. While version 1.X no. I'd like to run one test case per version to detect whether they are configured as I expect.
- git plugin version +2.4.1 allows git reference cache repos, so I'd like to test also different versions.
At the moment I need to test it manually with the hpi:run
Does the ATH allow this use case?
Cheers