Skip to content

Commit 4e05b9a

Browse files
authored
Merge pull request jenkinsci#209 from er1c/java8
Java8 & jenkins.version 2.60.3
2 parents 14b056a + 08eba2f commit 4e05b9a

16 files changed

Lines changed: 156 additions & 85 deletions

File tree

.mvn/wrapper/MavenWrapperDownloader.java

100755100644
File mode changed.

pom.xml

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.jenkins-ci.plugins</groupId>
77
<artifactId>plugin</artifactId>
8-
<version>2.6</version>
8+
<version>3.36</version>
99
<relativePath />
1010
</parent>
1111

@@ -47,14 +47,12 @@
4747
</issueManagement>
4848

4949
<properties>
50-
<jenkins.version>1.625.3</jenkins.version>
51-
<jenkins-test-harness.version>1.625.3</jenkins-test-harness.version>
50+
<jenkins.version>2.60.3</jenkins.version>
5251
<release.skipTests>false</release.skipTests>
5352
<maven.javadoc.skip>true</maven.javadoc.skip>
5453
<findbugs-maven-plugin.version>3.0.2</findbugs-maven-plugin.version>
5554
<concurrency>1</concurrency>
56-
<java.level>7</java.level>
57-
<hpi-plugin.version>1.120</hpi-plugin.version>
55+
<java.level>8</java.level>
5856
<workflow.version>1.14.2</workflow.version>
5957
</properties>
6058

@@ -76,7 +74,7 @@
7674
<dependency>
7775
<groupId>org.apache.commons</groupId>
7876
<artifactId>commons-lang3</artifactId>
79-
<version>3.4</version>
77+
<version>3.7</version>
8078
</dependency>
8179

8280
<dependency>
@@ -113,7 +111,7 @@
113111
<dependency>
114112
<groupId>org.jenkins-ci.plugins</groupId>
115113
<artifactId>credentials</artifactId>
116-
<version>2.1.8</version>
114+
<version>2.1.13</version>
117115
</dependency>
118116

119117
<dependency>
@@ -125,13 +123,13 @@
125123
<dependency>
126124
<groupId>org.jenkins-ci.plugins</groupId>
127125
<artifactId>structs</artifactId>
128-
<version>1.10</version>
126+
<version>1.17</version>
129127
</dependency>
130128

131129
<dependency>
132130
<groupId>org.jenkins-ci.plugins</groupId>
133131
<artifactId>token-macro</artifactId>
134-
<version>1.11</version>
132+
<version>1.12.1</version>
135133
</dependency>
136134

137135
<dependency>
@@ -140,24 +138,26 @@
140138
<version>2.0</version>
141139
</dependency>
142140

143-
<dependency><!-- exists in the core -->
141+
<dependency>
144142
<groupId>org.jenkins-ci.modules</groupId>
145143
<artifactId>instance-identity</artifactId>
146-
<version>1.3</version>
147-
<scope>provided</scope>
144+
<version>2.1</version><!-- Version matches https://mvnrepository.com/artifact/org.jenkins-ci.main/jenkins-war/2.60.3 -->
145+
<scope>provided</scope><!-- https://wiki.jenkins.io/display/JENKINS/Instance+Identity "add a provided scope dependency to this module into your plugin" -->
148146
</dependency>
149147

150-
<!--TEST DEPS-->
151-
<dependency> <!-- from org.eclipse.jetty:jetty-server:9.2.15.v20160210 -->
148+
<dependency>
152149
<groupId>javax.servlet</groupId>
153150
<artifactId>javax.servlet-api</artifactId>
154-
<scope>test</scope>
151+
<scope>provided</scope><!-- Provided by core: https://mvnrepository.com/artifact/org.jenkins-ci.main/jenkins-core/2.60.3 -->
155152
</dependency>
156153

154+
<!--TEST DEPS-->
155+
156+
<!-- 4.5.3 used by rest-assured -->
157157
<dependency>
158-
<groupId>org.apache.httpcomponents</groupId>
159-
<artifactId>httpclient</artifactId>
160-
<version>4.5.2</version>
158+
<groupId>org.jenkins-ci.plugins</groupId>
159+
<artifactId>apache-httpcomponents-client-4-api</artifactId>
160+
<version>4.5.3-2.1</version>
161161
<scope>test</scope>
162162
</dependency>
163163

@@ -182,16 +182,31 @@
182182
<scope>test</scope>
183183
</dependency>
184184

185+
<!-- For GlobalMatrixAuthorizationStrategy -->
186+
<dependency>
187+
<groupId>org.jenkins-ci.plugins</groupId>
188+
<artifactId>matrix-auth</artifactId>
189+
<version>1.1</version>
190+
<scope>test</scope>
191+
</dependency>
192+
185193
<dependency>
186194
<groupId>org.jenkins-ci.plugins.workflow</groupId>
187-
<artifactId>workflow-job</artifactId>
195+
<artifactId>workflow-cps</artifactId>
188196
<version>${workflow.version}</version>
189197
<scope>test</scope>
198+
<exclusions>
199+
<exclusion>
200+
<!-- TODO: Remove this exclusion after upgrading to a more recent workflow-* versions -->
201+
<groupId>org.jenkins-ci.ui</groupId>
202+
<artifactId>jquery-detached</artifactId>
203+
</exclusion>
204+
</exclusions>
190205
</dependency>
191206

192207
<dependency>
193208
<groupId>org.jenkins-ci.plugins.workflow</groupId>
194-
<artifactId>workflow-cps</artifactId>
209+
<artifactId>workflow-job</artifactId>
195210
<version>${workflow.version}</version>
196211
<scope>test</scope>
197212
</dependency>
@@ -212,7 +227,7 @@
212227
<classifier>standalone</classifier>
213228
<exclusions>
214229
<exclusion>
215-
<groupId>org.mortbay.jetty</groupId>
230+
<groupId>org.eclipse.jetty</groupId>
216231
<artifactId>jetty</artifactId>
217232
</exclusion>
218233
<exclusion>
@@ -246,17 +261,10 @@
246261
</dependency>
247262

248263
<dependency>
249-
<groupId>com.jayway.restassured</groupId>
264+
<groupId>io.rest-assured</groupId>
250265
<artifactId>rest-assured</artifactId>
251-
<!--1.7.2 is the last version that use a compatible groovy version-->
252-
<version>1.7.2</version>
266+
<version>3.3.0</version>
253267
<scope>test</scope>
254-
<exclusions>
255-
<exclusion>
256-
<groupId>org.apache.httpcomponents</groupId>
257-
<artifactId>*</artifactId>
258-
</exclusion>
259-
</exclusions>
260268
</dependency>
261269

262270
</dependencies>

src/main/java/com/cloudbees/jenkins/GitHubPushCause.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import java.io.File;
66
import java.io.IOException;
7+
import java.util.Objects;
78

89
import static java.lang.String.format;
910
import static org.apache.commons.lang3.StringUtils.trimToEmpty;
@@ -37,5 +38,19 @@ public GitHubPushCause(File pollingLog, String pusher) throws IOException {
3738
public String getShortDescription() {
3839
return format("Started by GitHub push by %s", trimToEmpty(pushedBy));
3940
}
41+
42+
@Override
43+
public boolean equals(Object o) {
44+
return o instanceof GitHubPushCause
45+
&& Objects.equals(this.pushedBy, ((GitHubPushCause) o).pushedBy)
46+
&& super.equals(o);
47+
}
48+
49+
@Override
50+
public int hashCode() {
51+
int hash = super.hashCode();
52+
hash = 89 * hash + Objects.hash(this.pushedBy);
53+
return hash;
54+
}
4055
}
4156

src/main/java/com/cloudbees/jenkins/GitHubPushTrigger.java

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import jenkins.model.Jenkins;
2222
import jenkins.model.ParameterizedJobMixIn;
2323
import jenkins.scm.api.SCMEvent;
24+
import jenkins.triggers.SCMTriggerItem;
2425
import jenkins.triggers.SCMTriggerItem.SCMTriggerItems;
2526
import org.apache.commons.jelly.XMLOutput;
2627
import org.jenkinsci.plugins.github.GitHubPlugin;
@@ -37,6 +38,7 @@
3738
import org.slf4j.Logger;
3839
import org.slf4j.LoggerFactory;
3940

41+
import javax.annotation.Nonnull;
4042
import javax.inject.Inject;
4143
import java.io.File;
4244
import java.io.IOException;
@@ -48,11 +50,13 @@
4850
import java.util.Collections;
4951
import java.util.Date;
5052
import java.util.List;
53+
import java.util.Objects;
5154
import java.util.Set;
5255
import java.util.concurrent.Executors;
5356
import java.util.concurrent.ThreadFactory;
5457

5558
import static org.apache.commons.lang3.StringUtils.isEmpty;
59+
import static org.apache.commons.lang3.Validate.notNull;
5660
import static org.jenkinsci.plugins.github.util.JobInfoHelpers.asParameterizedJobMixIn;
5761

5862
/**
@@ -91,22 +95,33 @@ public void onPost(String triggeredByUser) {
9195
* Called when a POST is made.
9296
*/
9397
public void onPost(final GitHubTriggerEvent event) {
98+
if (Objects.isNull(job)) {
99+
return; // nothing to do
100+
}
101+
102+
Job<?, ?> currentJob = notNull(job, "Job can't be null");
103+
94104
final String pushBy = event.getTriggeredByUser();
95105
DescriptorImpl d = getDescriptor();
96106
d.checkThreadPoolSizeAndUpdateIfNecessary();
97107
d.queue.execute(new Runnable() {
98108
private boolean runPolling() {
99109
try {
100-
StreamTaskListener listener = new StreamTaskListener(getLogFile());
110+
StreamTaskListener listener = new StreamTaskListener(getLogFileForJob(currentJob));
101111

102112
try {
103113
PrintStream logger = listener.getLogger();
114+
104115
long start = System.currentTimeMillis();
105116
logger.println("Started on " + DateFormat.getDateTimeInstance().format(new Date()));
106117
if (event.getOrigin() != null) {
107118
logger.format("Started by event from %s on %tc%n", event.getOrigin(), event.getTimestamp());
108119
}
109-
boolean result = SCMTriggerItems.asSCMTriggerItem(job).poll(listener).hasChanges();
120+
SCMTriggerItem item = SCMTriggerItems.asSCMTriggerItem(currentJob);
121+
if (null == item) {
122+
throw new IllegalStateException("Job is not an SCMTriggerItem: " + currentJob);
123+
}
124+
boolean result = item.poll(listener).hasChanges();
110125
logger.println("Done. Took " + Util.getTimeSpanString(System.currentTimeMillis() - start));
111126
if (result) {
112127
logger.println("Changes found");
@@ -135,16 +150,18 @@ public void run() {
135150
if (runPolling()) {
136151
GitHubPushCause cause;
137152
try {
138-
cause = new GitHubPushCause(getLogFile(), pushBy);
153+
cause = new GitHubPushCause(getLogFileForJob(currentJob), pushBy);
139154
} catch (IOException e) {
140155
LOGGER.warn("Failed to parse the polling log", e);
141156
cause = new GitHubPushCause(pushBy);
142157
}
143-
if (asParameterizedJobMixIn(job).scheduleBuild(cause)) {
144-
LOGGER.info("SCM changes detected in " + job.getFullName()
145-
+ ". Triggering #" + job.getNextBuildNumber());
158+
159+
if (asParameterizedJobMixIn(currentJob).scheduleBuild(cause)) {
160+
LOGGER.info("SCM changes detected in " + currentJob.getFullName()
161+
+ ". Triggering #" + currentJob.getNextBuildNumber());
146162
} else {
147-
LOGGER.info("SCM changes detected in " + job.getFullName() + ". Job is already in the queue");
163+
LOGGER.info("SCM changes detected in " + currentJob.getFullName()
164+
+ ". Job is already in the queue");
148165
}
149166
}
150167
}
@@ -155,6 +172,17 @@ public void run() {
155172
* Returns the file that records the last/current polling activity.
156173
*/
157174
public File getLogFile() {
175+
try {
176+
return getLogFileForJob(notNull(job, "Job can't be null!"));
177+
} catch (IOException ex) {
178+
throw new RuntimeException(ex);
179+
}
180+
}
181+
182+
/**
183+
* Returns the file that records the last/current polling activity.
184+
*/
185+
private File getLogFileForJob(@Nonnull Job job) throws IOException {
158186
return new File(job.getRootDir(), "github-polling.log");
159187
}
160188

@@ -234,7 +262,7 @@ public String getUrlName() {
234262
}
235263

236264
public String getLog() throws IOException {
237-
return Util.loadFile(getLogFile());
265+
return Util.loadFile(getLogFileForJob(job));
238266
}
239267

240268
/**
@@ -243,7 +271,7 @@ public String getLog() throws IOException {
243271
* @since 1.350
244272
*/
245273
public void writeLogTo(XMLOutput out) throws IOException {
246-
new AnnotatedLargeText<GitHubWebHookPollingAction>(getLogFile(), Charsets.UTF_8, true, this)
274+
new AnnotatedLargeText<GitHubWebHookPollingAction>(getLogFileForJob(job), Charsets.UTF_8, true, this)
247275
.writeHtmlTo(0, out.asWriter());
248276
}
249277
}

src/main/java/com/cloudbees/jenkins/GitHubTriggerEvent.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.cloudbees.jenkins;
22

3-
import javax.servlet.http.HttpServletRequest;
43
import jenkins.scm.api.SCMEvent;
54

65
/**
@@ -15,7 +14,7 @@ public class GitHubTriggerEvent {
1514
*/
1615
private final long timestamp;
1716
/**
18-
* The origin of the event (see {@link SCMEvent#originOf(HttpServletRequest)})
17+
* The origin of the event (see {@link SCMEvent#originOf(javax.servlet.http.HttpServletRequest)})
1918
*/
2019
private final String origin;
2120
/**

src/main/java/com/coravy/hudson/plugins/github/GithubProjectProperty.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public String getDisplayName() {
114114
}
115115

116116
@Override
117-
public JobProperty<?> newInstance(StaplerRequest req, JSONObject formData) throws FormException {
117+
public JobProperty<?> newInstance(@Nonnull StaplerRequest req, JSONObject formData) throws FormException {
118118
GithubProjectProperty tpp = req.bindJSON(
119119
GithubProjectProperty.class,
120120
formData.getJSONObject(GITHUB_PROJECT_BLOCK_NAME)

src/main/java/org/jenkinsci/plugins/github/admin/RequireAdminRights.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.kohsuke.stapler.interceptor.Interceptor;
77
import org.kohsuke.stapler.interceptor.InterceptorAnnotation;
88

9+
import javax.servlet.ServletException;
910
import java.lang.annotation.Retention;
1011
import java.lang.annotation.Target;
1112
import java.lang.reflect.InvocationTargetException;
@@ -29,7 +30,7 @@ class Processor extends Interceptor {
2930

3031
@Override
3132
public Object invoke(StaplerRequest request, StaplerResponse response, Object instance, Object[] arguments)
32-
throws IllegalAccessException, InvocationTargetException {
33+
throws IllegalAccessException, InvocationTargetException, ServletException {
3334

3435
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
3536
return target.invoke(request, response, instance, arguments);

src/main/java/org/jenkinsci/plugins/github/admin/RespondWithRedirect.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.kohsuke.stapler.interceptor.Interceptor;
77
import org.kohsuke.stapler.interceptor.InterceptorAnnotation;
88

9+
import javax.servlet.ServletException;
910
import java.lang.annotation.Retention;
1011
import java.lang.annotation.Target;
1112
import java.lang.reflect.InvocationTargetException;
@@ -30,7 +31,7 @@ class Processor extends Interceptor {
3031

3132
@Override
3233
public Object invoke(StaplerRequest request, StaplerResponse response, Object instance, Object[] arguments)
33-
throws IllegalAccessException, InvocationTargetException {
34+
throws IllegalAccessException, InvocationTargetException, ServletException {
3435
target.invoke(request, response, instance, arguments);
3536
throw new InvocationTargetException(new HttpRedirect("."));
3637
}

src/main/java/org/jenkinsci/plugins/github/admin/ValidateRepoName.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.kohsuke.stapler.interceptor.Interceptor;
77
import org.kohsuke.stapler.interceptor.InterceptorAnnotation;
88

9+
import javax.servlet.ServletException;
910
import java.lang.annotation.Retention;
1011
import java.lang.annotation.Target;
1112
import java.lang.reflect.InvocationTargetException;
@@ -34,7 +35,7 @@ class Processor extends Interceptor {
3435

3536
@Override
3637
public Object invoke(StaplerRequest request, StaplerResponse response, Object instance, Object[] arguments)
37-
throws IllegalAccessException, InvocationTargetException {
38+
throws IllegalAccessException, InvocationTargetException, ServletException {
3839

3940
if (!from(newArrayList(arguments)).firstMatch(instanceOf(GitHubRepositoryName.class)).isPresent()) {
4041
throw new InvocationTargetException(

0 commit comments

Comments
 (0)