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 Configuration as Code test + update to Jenkins 2.222.1 as a minimum requirement #13

Merged
merged 5 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
27 changes: 25 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.57</version>
<version>4.2</version>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<version>4.2</version>
<version>4.3</version>

<relativePath />
</parent>
<artifactId>jdk-tool</artifactId>
<version>1.5-SNAPSHOT</version>
<packaging>hpi</packaging>
<properties>
<jenkins.version>2.112</jenkins.version>
<jenkins.version>2.176.1</jenkins.version>
Copy link
Member

Choose a reason for hiding this comment

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

or

Suggested change
<jenkins.version>2.176.1</jenkins.version>
<jenkins.version>2.222.3</jenkins.version>

<java.level>8</java.level>
</properties>
<name>Oracle Java SE Development Kit Installer Plugin</name>
Expand Down Expand Up @@ -41,4 +41,27 @@
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.176.x</artifactId>
Copy link
Member

Choose a reason for hiding this comment

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

if so,

Suggested change
<artifactId>bom-2.176.x</artifactId>
<artifactId>bom-2.222.x</artifactId>

to match

<version>11</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins</groupId>
<artifactId>configuration-as-code</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jenkins.configuration-as-code</groupId>
<artifactId>test-harness</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
34 changes: 34 additions & 0 deletions src/test/java/hudson/tools/JDKInstallerCascTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package hudson.tools;

import hudson.ExtensionList;
import hudson.model.JDK;
import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
import org.junit.Rule;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class JDKInstallerCascTest {
@Rule
public JenkinsConfiguredWithCodeRule r = new JenkinsConfiguredWithCodeRule();

@ConfiguredWithCode("casc.yaml")
@Test
public void configuredByCasC() {
final JDK.DescriptorImpl descriptor = ExtensionList.lookupSingleton(JDK.DescriptorImpl.class);
assertEquals(1, descriptor.getInstallations().length);

JDK jdk = descriptor.getInstallations()[0];
assertEquals("jdk8", jdk.getName());
assertEquals("/jdk", jdk.getHome());

InstallSourceProperty installSourceProperty = jdk.getProperties().get(InstallSourceProperty.class);
assertEquals(1, installSourceProperty.installers.size());

JDKInstaller installer = installSourceProperty.installers.get(JDKInstaller.class);
assertEquals("jdk-8u181-oth-JPR", installer.id);
assertTrue(installer.acceptLicense);
}
}
11 changes: 11 additions & 0 deletions src/test/resources/hudson/tools/casc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tool:
jdk:
installations:
- home: "/jdk"
name: "jdk8"
properties:
- installSource:
installers:
- jdkInstaller:
acceptLicense: true
id: "jdk-8u181-oth-JPR"