Skip to content

Commit f95d8b9

Browse files
authored
Require Jenkins 2.479.3 or newer and Java 17 or newer (#2598)
1 parent 53fedb5 commit f95d8b9

File tree

20 files changed

+81
-82
lines changed

20 files changed

+81
-82
lines changed

Jenkinsfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if (JENKINS_URL == 'https://ci.jenkins.io/') {
88
],
99
// Tests were locking up and timing out on non-aci
1010
useContainerAgent: true,
11-
timeout: 90
11+
timeout: 120
1212
)
1313
return
1414
}

blueocean-bitbucket-pipeline/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
</dependency>
6161

6262
<dependency>
63-
<groupId>com.github.tomakehurst</groupId>
64-
<artifactId>wiremock-jre8-standalone</artifactId>
63+
<groupId>org.wiremock</groupId>
64+
<artifactId>wiremock-standalone</artifactId>
6565
<scope>test</scope>
6666
</dependency>
6767

blueocean-bitbucket-pipeline/src/main/java/io/jenkins/blueocean/blueocean_bitbucket_pipeline/AbstractBitbucketScm.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.cloudbees.plugins.credentials.CredentialsScope;
55
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
66
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
7+
import hudson.model.Descriptor;
78
import hudson.model.User;
89
import io.jenkins.blueocean.commons.ErrorMessage;
910
import io.jenkins.blueocean.commons.ServiceException;
@@ -211,8 +212,13 @@ public HttpResponse validateAndCreate(@JsonBody JSONObject request) {
211212

212213
validate(userName, password, apiUrl);
213214

214-
final StandardUsernamePasswordCredentials credential = new UsernamePasswordCredentialsImpl(CredentialsScope.USER,
215+
final StandardUsernamePasswordCredentials credential;
216+
try {
217+
credential = new UsernamePasswordCredentialsImpl(CredentialsScope.USER,
215218
createCredentialId(apiUrl), "Bitbucket server credentials", userName, password);
219+
} catch (Descriptor.FormException e) {
220+
throw new RuntimeException(e);
221+
}
216222

217223
//if credentials are wrong, this call will fail with 401 error
218224
validateCredential(apiUrl, credential);

blueocean-bitbucket-pipeline/src/main/java/io/jenkins/blueocean/blueocean_bitbucket_pipeline/server/BitbucketServerEndpoint.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import io.jenkins.blueocean.rest.impl.pipeline.scm.ScmServerEndpoint;
1111
import org.apache.commons.lang.StringUtils;
1212
import org.kohsuke.stapler.HttpResponse;
13+
import org.kohsuke.stapler.StaplerRequest;
1314
import org.kohsuke.stapler.StaplerResponse;
1415
import org.kohsuke.stapler.WebMethod;
1516
import org.kohsuke.stapler.verb.DELETE;
@@ -66,7 +67,12 @@ public HttpResponse validate(){
6667
Messages.bbserver_version_validation_error(
6768
version, BitbucketServerApi.MINIMUM_SUPPORTED_VERSION));
6869
}
69-
return ( req, rsp, node ) -> rsp.setStatus( 200);
70+
return new HttpResponse() {
71+
@Override
72+
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) {
73+
rsp.setStatus(200);
74+
}
75+
};
7076
}
7177

7278
@WebMethod(name="") @DELETE

blueocean-bitbucket-pipeline/src/test/resources/api/server/mappings/mapping-branches-default-C98AD.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id" : "3cb8ad8e-bf64-3779-b249-1c1ca33c783a",
2+
"id" : "c8935a42-83a8-48dd-8a37-cd5fdbdfd91d",
33
"request" : {
44
"url" : "/rest/api/1.0/projects/TESTP/repos/empty-repo-test/branches/default",
55
"method" : "GET"
@@ -20,5 +20,5 @@
2020
"Date" : "Wed, 21 Jun 2017 18:05:02 GMT"
2121
}
2222
},
23-
"uuid" : "3cb8ad8e-bf64-3779-b249-1c1ca33c783a"
23+
"uuid" : "c8935a42-83a8-48dd-8a37-cd5fdbdfd91d"
2424
}

blueocean-bitbucket-pipeline/src/test/resources/api/server/mappings/mapping-browse-README-head-master.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id" : "fcd61006-ea0c-3033-ac53-50210cdbb644",
2+
"id" : "57930fc2-4641-4326-be71-6ece35ac3e29",
33
"request" : {
44
"url" : "/rest/api/1.0/projects/TESTP/repos/pipeline-demo-test/browse/README.md?at=refs%2Fheads%2Fmaster",
55
"method" : "HEAD"
@@ -19,5 +19,5 @@
1919
"Date" : "Mon, 12 Jun 2017 14:15:28 GMT"
2020
}
2121
},
22-
"uuid" : "fcd61006-ea0c-3033-ac53-50210cdbb644"
22+
"uuid" : "57930fc2-4641-4326-be71-6ece35ac3e29"
2323
}

blueocean-bitbucket-pipeline/src/test/resources/api/server/mappings/mapping-empty-repo-branches-default-head.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id" : "1723ba44-da9f-3d78-932b-579607e6d20d",
2+
"id" : "d9aebd64-d855-4256-a491-e864ce979344",
33
"request" : {
44
"url" : "/rest/api/1.0/projects/TESTP/repos/empty-repo-test/branches/default",
55
"method" : "HEAD"
@@ -20,5 +20,5 @@
2020
"Date" : "Mon, 12 Jun 2017 15:27:38 GMT"
2121
}
2222
},
23-
"uuid" : "1723ba44-da9f-3d78-932b-579607e6d20d"
23+
"uuid" : "d9aebd64-d855-4256-a491-e864ce979344"
2424
}

blueocean-bitbucket-pipeline/src/test/resources/api/server/mappings/mapping-redirect-test.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id" : "d5434dae-88c5-3cdd-a506-11adb708a1ad",
2+
"id" : "89db82a7-cfcd-4332-9cfb-9a767920fbf0",
33
"request" : {
44
"url" : "/rest/api/1.0/test-redirect",
55
"method" : "GET"
@@ -19,5 +19,5 @@
1919
"Date" : "Wed, 12 Jul 2017 09:54:11 GMT"
2020
}
2121
},
22-
"uuid" : "d5434dae-88c5-3cdd-a506-11adb708a1ad"
22+
"uuid" : "89db82a7-cfcd-4332-9cfb-9a767920fbf0"
2323
}

blueocean-bitbucket-pipeline/src/test/resources/api/server/mappings/mapping-repos-pipeline-demo-test-PcCw8-1.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id" : "95be5f1c-6099-3d8f-a28a-b63da5386da6",
2+
"id" : "6c03c3f6-0180-42e3-a6e6-ff420047ee7e",
33
"request" : {
44
"url" : "/rest/api/1.0/projects/TESTP/repos/pipeline-demo-test/",
55
"method" : "GET"
@@ -20,5 +20,5 @@
2020
"Date" : "Wed, 21 Jun 2017 11:43:22 GMT"
2121
}
2222
},
23-
"uuid" : "95be5f1c-6099-3d8f-a28a-b63da5386da6"
23+
"uuid" : "6c03c3f6-0180-42e3-a6e6-ff420047ee7e"
2424
}

blueocean-bitbucket-pipeline/src/test/resources/api/server_wrong_version/mappings/bitbucket_rest_api_10_projects_testp_repos_pipeline-demo-test_browse_somefile-7269cd83-1af6-4134-9161-82360d678dcc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id" : "7269cd83-1af6-4134-9161-82360d678dcc",
2+
"id" : "920a160b-2c74-47b3-8033-cbf07756c608",
33
"name" : "bitbucket_rest_api_10_projects_testp_repos_pipeline-demo-test_browse_somefile",
44
"request" : {
55
"url" : "/rest/api/1.0/projects/TESTP/repos/pipeline-demo-test/browse/SomeFile",
@@ -23,7 +23,7 @@
2323
"Connection" : "close"
2424
}
2525
},
26-
"uuid" : "7269cd83-1af6-4134-9161-82360d678dcc",
26+
"uuid" : "920a160b-2c74-47b3-8033-cbf07756c608",
2727
"persistent" : true,
2828
"insertionIndex" : 68
2929
}

blueocean-bitbucket-pipeline/src/test/resources/api/server_wrong_version/mappings/mapping-1.0-application-properties-q4jwO.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id" : "d5434dae-88c5-3cdd-a506-11adb708a1ad",
2+
"id" : "d090987c-1d65-41bf-b291-6f2dfd6c943d",
33
"request" : {
44
"url" : "/rest/api/1.0/application-properties",
55
"method" : "GET"
@@ -18,5 +18,5 @@
1818
"Date" : "Wed, 12 Jul 2017 09:54:11 GMT"
1919
}
2020
},
21-
"uuid" : "d5434dae-88c5-3cdd-a506-11adb708a1ad"
21+
"uuid" : "d090987c-1d65-41bf-b291-6f2dfd6c943d"
2222
}

blueocean-git-pipeline/src/main/java/io/jenkins/blueocean/blueocean_git_pipeline/GitScm.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
1010
import edu.umd.cs.findbugs.annotations.NonNull;
1111
import hudson.Extension;
12+
import hudson.model.Descriptor;
1213
import hudson.model.User;
1314
import hudson.util.HttpResponses;
1415
import io.jenkins.blueocean.commons.DigestUtils;
@@ -314,12 +315,16 @@ private void createPWCredentials(String credentialId, User user, @JsonBody JSONO
314315
// Un-normalized repositoryUrl so the description matches user input.
315316
String description = String.format("%s for %s", CREDENTIAL_DESCRIPTION_PW, repositoryUrl);
316317

317-
final StandardUsernamePasswordCredentials newCredential =
318-
new UsernamePasswordCredentialsImpl(CredentialsScope.USER,
318+
final StandardUsernamePasswordCredentials newCredential;
319+
try {
320+
newCredential = new UsernamePasswordCredentialsImpl(CredentialsScope.USER,
319321
credentialId,
320322
description,
321323
requestUsername,
322324
requestPassword);
325+
} catch (Descriptor.FormException e) {
326+
throw new RuntimeException(e);
327+
}
323328

324329
try {
325330
if (existingCredential == null) {

blueocean-github-pipeline/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
</dependency>
5858

5959
<dependency>
60-
<groupId>com.github.tomakehurst</groupId>
61-
<artifactId>wiremock-jre8-standalone</artifactId>
60+
<groupId>org.wiremock</groupId>
61+
<artifactId>wiremock-standalone</artifactId>
6262
<scope>test</scope>
6363
</dependency>
6464

blueocean-github-pipeline/src/main/java/io/jenkins/blueocean/blueocean_github_pipeline/GithubScm.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.fasterxml.jackson.databind.ObjectReader;
77
import com.fasterxml.jackson.databind.ObjectWriter;
88
import hudson.Extension;
9+
import hudson.model.Descriptor;
910
import hudson.model.Item;
1011
import hudson.model.User;
1112
import hudson.tasks.Mailer;
@@ -334,9 +335,13 @@ public HttpResponse validateAndCreate(@JsonBody JSONObject request) {
334335
String credentialId = createCredentialId(getUri());
335336
StandardUsernamePasswordCredentials githubCredential =
336337
CredentialsUtils.findCredential(credentialId, StandardUsernamePasswordCredentials.class, new BlueOceanDomainRequirement());
337-
final StandardUsernamePasswordCredentials credential =
338-
new UsernamePasswordCredentialsImpl(CredentialsScope.USER, credentialId, getCredentialDescription(),
338+
final StandardUsernamePasswordCredentials credential;
339+
try {
340+
credential = new UsernamePasswordCredentialsImpl(CredentialsScope.USER, credentialId, getCredentialDescription(),
339341
authenticatedUser.getId(), accessToken);
342+
} catch (Descriptor.FormException e) {
343+
throw new RuntimeException(e);
344+
}
340345

341346
if(githubCredential == null) {
342347
CredentialsUtils.createCredentialsInUserStore(

blueocean-pipeline-api-impl/src/main/java/io/jenkins/blueocean/rest/impl/pipeline/PipelineNodeImpl.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@
3737
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
3838
import org.kohsuke.stapler.HttpResponse;
3939
import org.kohsuke.stapler.StaplerRequest;
40+
import org.kohsuke.stapler.StaplerResponse;
4041
import org.kohsuke.stapler.export.Exported;
4142
import org.slf4j.Logger;
4243
import org.slf4j.LoggerFactory;
4344

4445
import edu.umd.cs.findbugs.annotations.CheckForNull;
4546
import javax.servlet.http.HttpServletResponse;
47+
import java.io.IOException;
4648
import java.util.Collection;
4749
import java.util.Collections;
4850
import java.util.Date;
@@ -267,18 +269,24 @@ public HttpResponse restart(StaplerRequest request) {
267269
BlueQueueItem queueItem = QueueUtil.getQueuedItem( bluePipeline.getOrganization(), item, run.getParent());
268270

269271
if (queueItem != null) { // If the item is still queued
270-
return ( req, rsp, node1 ) -> {
272+
return new HttpResponse() {
273+
@Override
274+
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException {
271275
rsp.setStatus( HttpServletResponse.SC_OK );
272276
rsp.getOutputStream().print( Export.toJson( queueItem.toRun() ) );
277+
}
273278
};
274279
}
275280

276281
final WorkflowRun restartRun = getRun(run.getParent(), item.getId());
277282
if (restartRun != null) {
278-
return (req, rsp, node1 ) -> {
283+
return new HttpResponse() {
284+
@Override
285+
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException {
279286
rsp.setStatus( HttpServletResponse.SC_OK );
280287
rsp.getOutputStream().print( Export.toJson( new PipelineRunImpl(restartRun, parent,
281288
bluePipeline.getOrganization()) ) );
289+
}
282290
};
283291
} else { // For some reason could not be added to the queue
284292
throw new ServiceException.UnexpectedErrorException("Run was not added to queue.");

blueocean-pipeline-api-impl/src/main/java/io/jenkins/blueocean/rest/impl/pipeline/scm/AbstractScm.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
import io.jenkins.blueocean.rest.factory.organization.AbstractOrganization;
1111
import io.jenkins.blueocean.rest.factory.organization.OrganizationFactory;
1212
import io.jenkins.blueocean.rest.model.BlueOrganization;
13+
import java.io.IOException;
1314
import jenkins.model.ModifiableTopLevelItemGroup;
1415
import org.kohsuke.stapler.HttpResponse;
1516
import org.kohsuke.stapler.StaplerRequest;
17+
import org.kohsuke.stapler.StaplerResponse;
1618

1719
import edu.umd.cs.findbugs.annotations.CheckForNull;
1820
import edu.umd.cs.findbugs.annotations.NonNull;
@@ -35,9 +37,12 @@ protected User getAuthenticatedUser(){
3537
}
3638

3739
protected HttpResponse createResponse(final String credentialId) {
38-
return (req, rsp, node ) -> {
40+
return new HttpResponse() {
41+
@Override
42+
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException {
3943
rsp.setStatus(200);
4044
rsp.getWriter().print(JsonConverter.toJson( MapsHelper.of("credentialId", credentialId)));
45+
}
4146
};
4247
}
4348

blueocean-pipeline-api-impl/src/test/java/io/jenkins/blueocean/rest/impl/pipeline/RunImplTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,16 @@ public void pipelineLatestRunIncludesRunning() throws Exception {
209209
// Replay this - with limited retry
210210
String replayURL = String.format("/organizations/jenkins/pipelines/%s/runs/%s/replay/", p.getName(), idOfSecondRun);
211211
try {
212-
Thread.sleep(200);
212+
Thread.sleep(500);
213213

214214
request().crumb( getCrumb( j.jenkins ) ).post(replayURL).build(String.class);
215215
} catch (Exception e) {
216-
Thread.sleep(200);
216+
Thread.sleep(500);
217217
request().post(replayURL).build(String.class);
218218
}
219219

220220
// Sleep to make sure the build actually gets launched.
221-
Thread.sleep(1000);
221+
Thread.sleep(2000);
222222
WorkflowRun r3 = p.getLastBuild();
223223

224224
j.waitForMessage("Still waiting to schedule task", r3);
@@ -376,7 +376,7 @@ public void queuedAndRunningParallel() throws Exception {
376376

377377
SemaphoreStep.success("wait-a/1", null);
378378
// Sleep to make sure we get the a branch end node...
379-
Thread.sleep(1000);
379+
Thread.sleep(2000);
380380

381381
pipeline = request().get(String.format("/organizations/jenkins/pipelines/%s/", p.getName())).build(Map.class);
382382
latestRun = (Map) pipeline.get("latestRun");

blueocean-rest-impl/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@
124124
<scope>test</scope>
125125
</dependency>
126126
<dependency>
127-
<groupId>com.github.tomakehurst</groupId>
128-
<artifactId>wiremock-jre8-standalone</artifactId>
127+
<groupId>org.wiremock</groupId>
128+
<artifactId>wiremock-standalone</artifactId>
129129
<scope>test</scope>
130130
</dependency>
131131
<!-- only for ArtifactImplTest and write final field -->

blueocean-rest/src/main/java/io/jenkins/blueocean/rest/pageable/PagedResponse.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.kohsuke.stapler.interceptor.InterceptorAnnotation;
1010

1111
import javax.servlet.ServletException;
12+
import java.io.IOException;
1213
import java.lang.annotation.Retention;
1314
import java.lang.annotation.Target;
1415
import java.lang.reflect.InvocationTargetException;
@@ -51,7 +52,9 @@ public Object invoke(StaplerRequest request, StaplerResponse response, Object in
5152
}
5253
final Pageable<?> resp = (Pageable<?>) target.invoke(request, response, instance, arguments);
5354

54-
return (HttpResponse) ( req, rsp, node ) -> {
55+
return new HttpResponse() {
56+
@Override
57+
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
5558
int start = (req.getParameter("start") != null) ? Integer.parseInt(req.getParameter("start")) : 0;
5659
int limit = (req.getParameter("limit") != null) ? Integer.parseInt(req.getParameter("limit")) : DEFAULT_LIMIT;
5760

@@ -78,6 +81,7 @@ public Object invoke(StaplerRequest request, StaplerResponse response, Object in
7881
rsp.setHeader("Link", "<" + url + separator + "start=" + (start + limit) + "&limit="+limit + ">; rel=\"next\"");
7982

8083
Export.doJson(req, rsp, page);
84+
}
8185
};
8286
}
8387

0 commit comments

Comments
 (0)