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

Bump LTS to 2.479.x line #624

Merged
merged 6 commits into from
Jan 15, 2025
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
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ buildPlugin(
forkCount: '1C', // run this number of tests in parallel for faster feedback. If the number terminates with a 'C', the value will be multiplied by the number of available CPU cores
useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests
configurations: [
[platform: 'linux', jdk: 17],
[platform: 'linux', jdk: 21],
[platform: 'windows', jdk: 17],
])
20 changes: 10 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.86</version>
<version>5.4</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -52,17 +52,18 @@
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<jira-rest-client.version>5.2.7</jira-rest-client.version>
<fugue.version>4.7.2</fugue.version>
<!-- jenkins -->
<jenkins.version>2.440.3</jenkins.version>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.479</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<spotless.check.skip>false</spotless.check.skip>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.440.x</artifactId>
<version>3234.v5ca_5154341ef</version>
<artifactId>bom-${jenkins.baseline}.x</artifactId>
<version>3875.v1df09947cde6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -71,11 +72,6 @@
<artifactId>atlassian-plugins-core</artifactId>
<version>5.3.12</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20240303</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -234,6 +230,10 @@
<groupId>io.jenkins.plugins</groupId>
<artifactId>joda-time-api</artifactId>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>json-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/hudson/plugins/jira/CredentialsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.model.Descriptor.FormException;
import hudson.model.Item;
import hudson.model.Queue;
import hudson.model.queue.Tasks;
Expand Down Expand Up @@ -53,7 +54,7 @@ protected static StandardUsernamePasswordCredentials lookupSystemCredentials(
}

protected static StandardUsernamePasswordCredentials migrateCredentials(
@NonNull String username, String password, @CheckForNull URL url) {
@NonNull String username, String password, @CheckForNull URL url) throws FormException {
List<StandardUsernamePasswordCredentials> credentials = CredentialsMatchers.filter(
CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class,
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/hudson/plugins/jira/JiraSite.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import hudson.Util;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import hudson.model.Descriptor.FormException;
import hudson.model.Item;
import hudson.model.ItemGroup;
import hudson.model.Job;
Expand Down Expand Up @@ -306,7 +307,8 @@ public JiraSite(
boolean updateJiraIssueForAllStatus,
@CheckForNull String groupVisibility,
@CheckForNull String roleVisibility,
boolean useHTTPAuth) {
boolean useHTTPAuth)
throws FormException {
this(
url,
alternativeUrl,
Expand All @@ -332,7 +334,8 @@ public JiraSite(
boolean updateJiraIssueForAllStatus,
String groupVisibility,
String roleVisibility,
boolean useHTTPAuth) {
boolean useHTTPAuth)
throws FormException {
this(
url,
alternativeUrl,
Expand Down Expand Up @@ -646,8 +649,9 @@ public void setUpdateJiraIssueForAllStatus(boolean updateJiraIssueForAllStatus)
}

@SuppressWarnings("unused")
protected Object readResolve() {
protected Object readResolve() throws FormException {
JiraSite jiraSite;

if (credentialsId == null && userName != null && password != null) { // Migrate credentials
jiraSite = new JiraSite(
url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,24 @@
import hudson.ProxyConfiguration;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.Base64;
import java.util.Date;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jenkins.model.Jenkins;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.Callback;
import org.junit.After;
import org.junit.Assert;
import org.junit.Rule;
Expand Down Expand Up @@ -151,7 +150,7 @@ public void simple_post_with_proxy() throws Exception {
Assert.assertEquals("FOO", testHandler.postReceived);
}

public class ProxyTestHandler extends AbstractHandler {
public static class ProxyTestHandler extends Handler.Abstract {

String postReceived;

Expand All @@ -164,55 +163,50 @@ public class ProxyTestHandler extends AbstractHandler {
final String realm = "test_realm";

@Override
public void handle(
String target,
org.eclipse.jetty.server.Request jettyRequest,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
public boolean handle(
org.eclipse.jetty.server.Request request, org.eclipse.jetty.server.Response response, Callback callback)
throws IOException {

final String credentials = Base64.getEncoder().encodeToString((user + ":" + password).getBytes("UTF-8"));

jettyRequest.setHandled(true);

String authorization = request.getHeader(HttpHeader.PROXY_AUTHORIZATION.asString());
String authorization = request.getHeaders().get(HttpHeader.PROXY_AUTHORIZATION.asString());
if (authorization == null) {
response.setStatus(HttpStatus.PROXY_AUTHENTICATION_REQUIRED_407);
response.setHeader(HttpHeader.PROXY_AUTHENTICATE.asString(), "Basic realm=\"" + realm + "\"");
return;
response.getHeaders().add(HttpHeader.PROXY_AUTHENTICATE.asString(), "Basic realm=\"" + realm + "\"");
callback.succeeded();
return true;
} else {
String prefix = "Basic ";
if (authorization.startsWith(prefix)) {
String attempt = authorization.substring(prefix.length());
if (!credentials.equals(attempt)) {
return;
callback.succeeded();
return true;
}
}
}

if (StringUtils.equalsIgnoreCase("post", request.getMethod())) {
postReceived = IOUtils.toString(request.getReader());
postReceived = Content.Source.asString(request, StandardCharsets.UTF_8);
}
response.getWriter().write(CONTENT_RESPONSE);
Content.Sink.write(response, true, CONTENT_RESPONSE, callback);
return true;
}
}

public class TestHandler extends AbstractHandler {
public static class TestHandler extends Handler.Abstract {

String postReceived;

@Override
public void handle(
String target,
org.eclipse.jetty.server.Request jettyRequest,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
jettyRequest.setHandled(true);
public boolean handle(
org.eclipse.jetty.server.Request request, org.eclipse.jetty.server.Response response, Callback callback)
throws IOException {
if (StringUtils.equalsIgnoreCase("post", request.getMethod())) {
postReceived = IOUtils.toString(request.getReader());
postReceived = Content.Source.asString(request, StandardCharsets.UTF_8);
}
response.getWriter().write(CONTENT_RESPONSE);
Content.Sink.write(response, true, CONTENT_RESPONSE, callback);
return true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.cloudbees.plugins.credentials.domains.DomainSpecification;
import com.cloudbees.plugins.credentials.domains.HostnameSpecification;
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
import hudson.model.Descriptor.FormException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
Expand All @@ -29,7 +30,7 @@ public class CredentialsHelperTest {
public JenkinsRule r = new JenkinsRule();

@Test
public void lookupSystemCredentials() throws IOException {
public void lookupSystemCredentials() throws IOException, FormException {
assertNull(CredentialsHelper.lookupSystemCredentials("nonexistent-credentials-id", null));

StandardUsernamePasswordCredentials c =
Expand All @@ -41,7 +42,7 @@ public void lookupSystemCredentials() throws IOException {
}

@Test
public void lookupSystemCredentialsWithDomainRestriction() throws IOException {
public void lookupSystemCredentialsWithDomainRestriction() throws IOException, FormException {
Domain domain = new Domain(
"example",
"test domain",
Expand All @@ -56,7 +57,7 @@ public void lookupSystemCredentialsWithDomainRestriction() throws IOException {
}

@Test
public void migrateCredentials() throws MalformedURLException {
public void migrateCredentials() throws MalformedURLException, FormException {
assertThat(
CredentialsProvider.lookupStores(r.jenkins).iterator().next().getCredentials(Domain.global()), empty());

Expand All @@ -70,7 +71,7 @@ public void migrateCredentials() throws MalformedURLException {
}

@Test
public void migrateCredentialsWithExsitingCredentials() throws IOException {
public void migrateCredentialsWithExsitingCredentials() throws IOException, FormException {
Domain domain = new Domain(
"example",
"test domain",
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/hudson/plugins/jira/DescriptorImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Descriptor.FormException;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Item;
Expand Down Expand Up @@ -60,7 +61,7 @@ public class DescriptorImplTest {
JiraSite.Builder builder = spy(new JiraSite.Builder());

@Test
public void doFillCredentialsIdItems() throws IOException {
public void doFillCredentialsIdItems() throws IOException, FormException {

MockFolder dummy = r.createFolder("dummy");
r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
import hudson.model.Item;
import hudson.model.User;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Base64;
import java.util.HashMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jenkins.model.Jenkins;
import jenkins.security.ApiTokenProperty;
import net.sf.json.JSONObject;
import org.eclipse.jetty.ee9.servlet.DefaultServlet;
import org.eclipse.jetty.ee9.servlet.ServletContextHandler;
import org.eclipse.jetty.ee9.servlet.ServletHolder;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.htmlunit.HttpMethod;
import org.htmlunit.Page;
import org.htmlunit.WebRequest;
Expand Down
16 changes: 9 additions & 7 deletions src/test/java/hudson/plugins/jira/JiraSiteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.cloudbees.plugins.credentials.domains.DomainSpecification;
import com.cloudbees.plugins.credentials.domains.HostnameSpecification;
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
import hudson.model.Descriptor.FormException;
import hudson.model.FreeStyleProject;
import hudson.model.Job;
import hudson.plugins.jira.model.JiraIssue;
Expand Down Expand Up @@ -62,7 +63,7 @@ public void init() throws MalformedURLException {
}

@Test
public void createSessionWithProvidedCredentials() {
public void createSessionWithProvidedCredentials() throws FormException {
JiraSite site = new JiraSite(
validPrimaryUrl,
null,
Expand All @@ -82,7 +83,7 @@ public void createSessionWithProvidedCredentials() {

@Test
@Issue("JENKINS-64083")
public void createSessionWithGlobalCredentials() {
public void createSessionWithGlobalCredentials() throws FormException {
JiraSite site = new JiraSite(
validPrimaryUrl,
null,
Expand All @@ -101,7 +102,7 @@ public void createSessionWithGlobalCredentials() {
}

@Test
public void createSessionReturnsNullIfCredentialsIsNull() {
public void createSessionReturnsNullIfCredentialsIsNull() throws FormException {
JiraSite site = new JiraSite(
validPrimaryUrl,
null,
Expand All @@ -120,7 +121,7 @@ public void createSessionReturnsNullIfCredentialsIsNull() {
}

@Test
public void deserializeMigrateCredentials() throws MalformedURLException {
public void deserializeMigrateCredentials() throws MalformedURLException, FormException {
JiraSiteOld old = new JiraSiteOld(
validPrimaryUrl, null, ANY_USER, ANY_PASSWORD, false, false, null, false, null, null, true);

Expand Down Expand Up @@ -153,7 +154,7 @@ public void deserializeMigrateCredentials() throws MalformedURLException {
}

@Test
public void deserializeNormal() throws IOException {
public void deserializeNormal() throws IOException, FormException {
Domain domain = new Domain(
"example",
"test domain",
Expand Down Expand Up @@ -207,7 +208,8 @@ private static class JiraSiteOld extends JiraSite {
boolean updateJiraIssueForAllStatus,
String groupVisibility,
String roleVisibility,
boolean useHTTPAuth) {
boolean useHTTPAuth)
throws FormException {
super(
url,
alternativeUrl,
Expand All @@ -226,7 +228,7 @@ private static class JiraSiteOld extends JiraSite {

@Test
@WithoutJenkins
public void alternativeURLNotNull() {
public void alternativeURLNotNull() throws FormException {
JiraSite site = new JiraSite(
validPrimaryUrl,
exampleOrg,
Expand Down
Loading