Skip to content

Commit 0cac699

Browse files
committed
Merge remote-tracking branch 'upstream-jenkinsci/master'
# Conflicts: # src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/config/Config.java
2 parents d5751ad + b19b056 commit 0cac699

File tree

47 files changed

+897
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+897
-138
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ generated-sources
1717
hostkey.ser
1818
*.xml~
1919
/eclipse-classes
20+
.vscode/
21+
.factorypath

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ Each job can be configured with one Gerrit server.
2828

2929
# Environments
3030
* `linux`
31-
* `java-1.7`
31+
* `java-1.8`
3232
* `maven-3.3.3`
3333

34-
* Java 1.7: minimum development environment.
35-
* Java 8: Works.
36-
* Java 6 Runtime compatible
34+
* Java 8: needed development environment.
3735

3836
You should have no problem running the plugin on a Windows server.
3937

@@ -52,7 +50,7 @@ The _(build-config)_ directory contains "special" CheckStyle configurations and
5250
fail during the verification phase if you don't follow them.
5351

5452
mvn clean package
55-
53+
5654
Run findbugs for future reference or to make sure you haven't introduced any
5755
new warnings
5856

@@ -68,6 +66,10 @@ To test in a local Jenkins instance
6866

6967
mvn hpi:run
7068

69+
# Clean test environment
70+
71+
mvn clean
72+
rm /tmp/jenkins-testkey* hostkey.ser # Needed when changing SSH components versions
7173

7274
# License
7375

@@ -93,4 +95,3 @@ To test in a local Jenkins instance
9395
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
9496
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
9597
THE SOFTWARE.
96-

pom.xml

Lines changed: 102 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<parent>
44
<groupId>org.jenkins-ci.plugins</groupId>
55
<artifactId>plugin</artifactId>
6-
<version>2.30</version>
6+
<version>3.32</version>
77
<relativePath />
88
</parent>
99

1010
<groupId>com.sonyericsson.hudson.plugins.gerrit</groupId>
1111
<artifactId>gerrit-trigger</artifactId>
12-
<version>2.27.8-SNAPSHOT</version>
12+
<version>2.29.1-SNAPSHOT</version>
1313
<packaging>hpi</packaging>
1414
<name>Gerrit Trigger</name>
1515
<description>Integrates with Gerrit code review.</description>
@@ -53,24 +53,25 @@
5353
</developers>
5454

5555
<properties>
56-
<jenkins.version>1.609.3</jenkins.version>
57-
<!--<jenkins.version>2.5-SNAPSHOT</jenkins.version>-->
58-
<java.level>6</java.level>
56+
<jenkins.version>2.121.1</jenkins.version>
57+
<java.level>8</java.level>
5958
<no-test-jar>false</no-test-jar>
6059
<findbugs.failOnError>false</findbugs.failOnError>
6160
<concurrency>1C</concurrency>
6261
<powermock.version>1.6.2</powermock.version>
6362
<checkstyle.version>2.13</checkstyle.version>
6463
<mockito.version>1.10.19</mockito.version>
65-
<workflow.version>1.14</workflow.version>
66-
<workflow.version.test>1.14.1-beta-1</workflow.version.test>
64+
<scm-api.version>2.2.6</scm-api.version>
65+
<!--<workflow-cps.version>2.61</workflow-cps.version>-->
66+
<!--<workflow-job.version>2.26</workflow-job.version>-->
67+
<!--<workflow-step-api.version>2.17</workflow-step-api.version>-->
6768
</properties>
6869

6970
<dependencies>
7071
<dependency>
7172
<groupId>com.sonymobile.tools.gerrit</groupId>
7273
<artifactId>gerrit-events</artifactId>
73-
<version>2.12.0</version>
74+
<version>2.13.0</version>
7475
<exclusions>
7576
<exclusion>
7677
<!-- json-lib-2.4-jenkins-2 is provided by core/stapler -->
@@ -83,18 +84,17 @@
8384
<dependency>
8485
<groupId>org.jenkins-ci.plugins</groupId>
8586
<artifactId>structs</artifactId>
86-
<version>1.1</version>
87+
<version>1.17</version>
8788
</dependency>
8889
<dependency>
8990
<groupId>org.jenkins-ci.plugins</groupId>
9091
<artifactId>git</artifactId>
91-
<version>2.3</version>
92+
<version>2.4.3</version>
9293
<optional>true</optional>
9394
</dependency>
9495
<dependency>
9596
<groupId>org.jenkins-ci.plugins</groupId>
9697
<artifactId>git-client</artifactId>
97-
<version>1.11.1</version>
9898
<optional>true</optional>
9999
</dependency>
100100
<dependency>
@@ -106,38 +106,97 @@
106106
<dependency>
107107
<groupId>org.jenkins-ci.plugins</groupId>
108108
<artifactId>rabbitmq-consumer</artifactId>
109-
<version>2.2</version>
109+
<version>2.8</version>
110110
<optional>true</optional>
111111
</dependency>
112112
<dependency>
113113
<groupId>org.jenkins-ci.plugins</groupId>
114114
<artifactId>support-core</artifactId>
115-
<version>2.31</version>
115+
<version>2.43</version>
116116
<optional>true</optional>
117117
</dependency>
118118
<dependency>
119119
<groupId>commons-net</groupId>
120120
<artifactId>commons-net</artifactId>
121-
<version>2.0</version>
121+
<version>3.6</version>
122+
</dependency>
123+
<dependency>
124+
<groupId>org.jenkins-ci.plugins</groupId>
125+
<artifactId>credentials</artifactId>
126+
<version>2.1.10</version>
127+
<scope>test</scope>
122128
</dependency>
123129
<dependency>
124130
<groupId>org.jenkins-ci.plugins</groupId>
125131
<artifactId>junit</artifactId>
126132
<version>1.12</version>
127133
<scope>test</scope>
128134
</dependency>
135+
<dependency>
136+
<groupId>org.jenkins-ci.plugins</groupId>
137+
<artifactId>scm-api</artifactId>
138+
<version>${scm-api.version}</version>
139+
</dependency>
140+
<dependency>
141+
<groupId>org.jenkins-ci.plugins</groupId>
142+
<artifactId>pipeline-build-step</artifactId>
143+
<version>2.4</version>
144+
<!--<scope>test</scope>-->
145+
</dependency>
146+
<dependency>
147+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
148+
<artifactId>workflow-api</artifactId>
149+
<version>2.30</version>
150+
<scope>test</scope>
151+
</dependency>
152+
<dependency>
153+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
154+
<artifactId>workflow-basic-steps</artifactId>
155+
<version>2.4</version>
156+
</dependency>
157+
<dependency>
158+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
159+
<artifactId>workflow-cps</artifactId>
160+
<version>2.61</version>
161+
<scope>test</scope>
162+
</dependency>
163+
<dependency>
164+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
165+
<artifactId>workflow-durable-task-step</artifactId>
166+
<version>2.18</version>
167+
<!--<scope>test</scope>-->
168+
</dependency>
169+
<dependency>
170+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
171+
<artifactId>workflow-job</artifactId>
172+
<version>2.26</version>
173+
<scope>test</scope>
174+
</dependency>
129175
<dependency>
130176
<groupId>org.jenkins-ci.plugins.workflow</groupId>
131-
<artifactId>workflow-aggregator</artifactId>
132-
<version>${workflow.version.test}</version>
177+
<artifactId>workflow-scm-step</artifactId>
178+
<version>2.4</version>
133179
<scope>test</scope>
134180
</dependency>
135181
<dependency>
136182
<groupId>org.jenkins-ci.plugins.workflow</groupId>
137183
<artifactId>workflow-step-api</artifactId>
138-
<version>${workflow.version}</version>
184+
<version>2.17</version>
139185
<optional>true</optional>
140186
</dependency>
187+
<dependency>
188+
<groupId>org.jenkins-ci.plugins.workflow</groupId>
189+
<artifactId>workflow-support</artifactId>
190+
<version>2.21</version>
191+
<scope>test</scope>
192+
</dependency>
193+
<dependency>
194+
<!-- Used for test with matrix permissions -->
195+
<groupId>org.jenkins-ci.plugins</groupId>
196+
<artifactId>matrix-auth</artifactId>
197+
<version>2.3</version>
198+
<scope>test</scope>
199+
</dependency>
141200
<dependency>
142201
<groupId>org.easymock</groupId>
143202
<artifactId>easymock</artifactId>
@@ -147,17 +206,16 @@
147206
<dependency>
148207
<groupId>org.slf4j</groupId>
149208
<artifactId>slf4j-api</artifactId>
150-
<version>1.6.1</version>
209+
<version>1.7.25</version>
151210
</dependency>
152211
<dependency>
153212
<groupId>org.slf4j</groupId>
154213
<artifactId>slf4j-jdk14</artifactId>
155-
<version>1.6.1</version>
214+
<version>1.7.25</version>
156215
</dependency>
157216
<dependency>
158217
<groupId>junit</groupId>
159218
<artifactId>junit</artifactId>
160-
<version>4.11</version>
161219
<scope>test</scope>
162220
</dependency>
163221
<dependency>
@@ -185,11 +243,17 @@
185243
<scope>test</scope>
186244
</dependency>
187245
<dependency>
246+
<groupId>org.jenkins-ci.plugins</groupId>
247+
<artifactId>pipeline-stage-step</artifactId>
248+
<version>2.3</version>
249+
<scope>test</scope>
250+
</dependency>
251+
<!-- <dependency>
188252
<groupId>org.apache.sshd</groupId>
189253
<artifactId>sshd-core</artifactId>
190-
<version>0.13.0</version>
254+
<version>1.7.0</version>
191255
<scope>test</scope>
192-
</dependency>
256+
</dependency> -->
193257
<dependency>
194258
<groupId>com.google.guava</groupId>
195259
<artifactId>guava</artifactId>
@@ -208,6 +272,20 @@
208272
<scope>provided</scope>
209273
</dependency>
210274
</dependencies>
275+
<dependencyManagement>
276+
<dependencies>
277+
<dependency>
278+
<groupId>org.jenkins-ci.plugins</groupId>
279+
<artifactId>git-client</artifactId>
280+
<version>1.19.6</version>
281+
</dependency>
282+
<dependency>
283+
<groupId>org.jenkins-ci.plugins</groupId>
284+
<artifactId>script-security</artifactId>
285+
<version>1.48</version>
286+
</dependency>
287+
</dependencies>
288+
</dependencyManagement>
211289
<repositories>
212290
<repository>
213291
<id>repo.jenkins-ci.org</id>
@@ -305,8 +383,8 @@
305383
<configuration>
306384
<signature>
307385
<groupId>org.codehaus.mojo.signature</groupId>
308-
<artifactId>java16</artifactId>
309-
<version>1.1</version>
386+
<artifactId>java18</artifactId>
387+
<version>1.0</version>
310388
</signature>
311389
</configuration>
312390
<executions>

src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritProjectListUpdater.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ private void tryLoadProjectList() {
230230
}
231231
}
232232
try {
233-
logger.info("Trying to load project list.");
234233
if (isConnected()) {
234+
logger.info("Trying to load project list.");
235235
IGerritHudsonTriggerConfig activeConfig = getConfig();
236236
SshConnection sshConnection = SshConnectionFactory.getConnection(
237237
activeConfig.getGerritHostName(),
@@ -247,6 +247,9 @@ private void tryLoadProjectList() {
247247
logger.warn("Project list from {} contains 0 projects", serverName);
248248
}
249249
sshConnection.disconnect();
250+
} else {
251+
logger.warn("Could not connect to Gerrit server when updating Gerrit project list: "
252+
+ "Server is not connected (timeout)");
250253
}
251254
} catch (SshException ex) {
252255
logger.warn("Could not connect to Gerrit server when updating Gerrit project list: ", ex);
@@ -341,4 +344,3 @@ public String getDisplayName() {
341344
return StringUtil.getDefaultDisplayNameForSpecificServer(this, getServerName());
342345
}
343346
}
344-

src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritServer.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,12 @@ public synchronized void startConnection() {
553553
if (gerritConnection == null) {
554554
logger.debug("Starting Gerrit connection...");
555555
gerritConnection = new GerritConnection(name, config);
556-
gerritEventManager.setIgnoreEMail(name, config.getGerritEMail());
556+
if (config.isTriggerOnAllComments()) {
557+
logger.info("Will trigger on all comments, even from the configured user.");
558+
} else {
559+
logger.info("Will skip comments added by " + config.getGerritUserName());
560+
gerritEventManager.setIgnoreEMail(name, config.getGerritEMail());
561+
}
557562
gerritConnection.setHandler(gerritEventManager);
558563
gerritConnection.addListener(gerritConnectionListener);
559564
gerritConnection.addListener(projectListUpdater);
@@ -1326,7 +1331,7 @@ public FormValidation doIntegerCheck(
13261331
Integer.parseInt(value);
13271332
return FormValidation.ok();
13281333
} catch (NumberFormatException e) {
1329-
return FormValidation.error(hudson.model.Messages.Hudson_NotANumber());
1334+
return FormValidation.error(Messages.NotANumber());
13301335
}
13311336
}
13321337

@@ -1346,7 +1351,7 @@ public FormValidation doEmptyOrIntegerCheck(
13461351
Integer.parseInt(value);
13471352
return FormValidation.ok();
13481353
} catch (NumberFormatException e) {
1349-
return FormValidation.error(hudson.model.Messages.Hudson_NotANumber());
1354+
return FormValidation.error(Messages.NotANumber());
13501355
}
13511356
}
13521357
}

src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/JenkinsAwareGerritHandler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
package com.sonyericsson.hudson.plugins.gerrit.trigger;
2525

26+
import hudson.security.ACL;
27+
import hudson.security.ACLContext;
2628
import org.slf4j.Logger;
2729
import org.slf4j.LoggerFactory;
2830

@@ -73,8 +75,10 @@ public void notifyListeners(GerritEvent event) {
7375
}
7476
}
7577

76-
// The read deal
77-
super.notifyListeners(event);
78+
try (ACLContext ctx = ACL.as(ACL.SYSTEM)) {
79+
// The read deal
80+
super.notifyListeners(event);
81+
}
7882

7983
// //Notify lifecycle listeners.
8084
if (event instanceof GerritEventLifecycle) {

src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/SystemEventThread.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
*/
2424
package com.sonyericsson.hudson.plugins.gerrit.trigger;
2525

26-
import org.acegisecurity.context.SecurityContext;
27-
import org.acegisecurity.context.SecurityContextHolder;
28-
2926
import hudson.security.ACL;
27+
import hudson.security.ACLContext;
3028

3129
import com.sonymobile.tools.gerrit.gerritevents.workers.Coordinator;
3230
import com.sonymobile.tools.gerrit.gerritevents.workers.EventThread;
@@ -61,11 +59,8 @@ public SystemEventThread(Coordinator coordinator) {
6159
*/
6260
@Override
6361
public void run() {
64-
SecurityContext old = ACL.impersonate(ACL.SYSTEM);
65-
try {
62+
try (ACLContext ctx = ACL.as(ACL.SYSTEM)) {
6663
super.run();
67-
} finally {
68-
SecurityContextHolder.setContext(old);
6964
}
7065
}
7166
}

0 commit comments

Comments
 (0)