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

Update dependencies #775

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
62 changes: 40 additions & 22 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.2</version>
<version>3.57</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -51,12 +51,13 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<workflow.version>1.4</workflow.version>
<jenkins.version>2.7</jenkins.version>
<jenkins.version>2.230</jenkins.version>

Choose a reason for hiding this comment

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

This means that the plugin won't be compatible with older Jenkins (namely no current LTS will be able to use it). Probably you'd rather support several LTS.

I personnaly would choose something like 2.190 or 2.176 but I don't have a lot of experience to choose this others might have better advices. You can also have a look to https://stats.jenkins.io/pluginversions/ghprb.html to decide.

<powermock.version>1.6.2</powermock.version>
<java.level>7</java.level>
<java.level>8</java.level>
<findbugs.failOnError>false</findbugs.failOnError>
<checkstyle.version>6.7</checkstyle.version>
<checkstyle.plugin.version>2.17</checkstyle.plugin.version>
<slf4jVersion>1.7.26</slf4jVersion>
</properties>

<!--
Expand All @@ -78,12 +79,12 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
<version>2.1.0</version>
<version>2.6.3</version>

Choose a reason for hiding this comment

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

Relying on the BOM (see doc https://jenkins.io/doc/developer/plugin-development/dependency-management/) would avoid manually setting up versions for the plugin dependencies.

</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>symbol-annotation</artifactId>
<version>1.9</version>
<version>1.20</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
Expand All @@ -93,17 +94,17 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1.25</version>
<version>1.71</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.11</version>
<version>2.4.12</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.9.2</version>
<version>1.10.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand All @@ -118,20 +119,25 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>bouncycastle-api</artifactId>
<version>2.16.1</version>
<version>2.18</version>
</dependency>

<!-- end added dependencies because of maven enforcer plugin -->

<dependency>
<groupId>com.coravy.hudson.plugins.github</groupId>
<artifactId>github</artifactId>
<version>1.27.0</version>
<version>1.29.5</version>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
<version>1.11</version>
<version>1.14</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -141,18 +147,30 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git</artifactId>
<version>3.3.1</version>
<version>4.2.2</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>job-dsl</artifactId>
<version>1.63</version>
<version>1.77</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -182,7 +200,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>token-macro</artifactId>
<version>2.1</version>
<version>2.12</version>
<optional>true</optional>
</dependency>
<dependency>
Expand All @@ -194,7 +212,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>2.1.14</version>
<version>2.3.5</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -204,7 +222,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.9</version>
<version>1.20</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -261,8 +279,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import hudson.util.ListBoxModel;
import hudson.util.Secret;
import jenkins.model.Jenkins;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang.StringUtils;
import org.bouncycastle.util.encoders.Hex;
import org.jenkinsci.plugins.plaincredentials.StringCredentials;
import org.kohsuke.github.GHAuthorization;
import org.kohsuke.github.GHCommitState;
Expand Down Expand Up @@ -146,7 +146,7 @@ public boolean checkSignature(String body, String signature) {
Mac mac = Mac.getInstance(algorithm);
mac.init(keySpec);
byte[] localSignatureBytes = mac.doFinal(body.getBytes("UTF-8"));
String localSignature = Hex.encodeHexString(localSignatureBytes);
String localSignature = Hex.toHexString(localSignatureBytes);
if (!localSignature.equals(expected)) {
LOGGER.log(Level.SEVERE, "Local signature {0} does not match external signature {1}",
new Object[] {localSignature, expected});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import hudson.model.listeners.SaveableListener;
import hudson.util.Secret;
import jenkins.model.Jenkins;
import jenkins.util.SystemProperties;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.ghprb.extensions.GhprbCommentAppender;
import org.jenkinsci.plugins.ghprb.extensions.GhprbCommitStatusException;
Expand Down Expand Up @@ -53,8 +52,8 @@ public class GhprbRepository implements Saveable {

private static final transient EnumSet<GHEvent> HOOK_EVENTS = EnumSet.of(GHEvent.ISSUE_COMMENT, GHEvent.PULL_REQUEST);

private static final transient boolean INSECURE_WEBHOOKS = SystemProperties.getBoolean(
GhprbRepository.class.getName() + ".webhook.insecure", false);
private static final transient boolean INSECURE_WEBHOOKS = Boolean.parseBoolean(
System.getProperty(GhprbRepository.class.getName() + ".webhook.insecure", "false"));

private final String reponame;

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/jenkinsci/plugins/ghprb/GhprbTrigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import hudson.util.ListBoxModel.Option;
import jenkins.model.Jenkins;
import jenkins.model.ParameterizedJobMixIn;
import jenkins.util.SystemProperties;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.ghprb.extensions.GhprbBuildStep;
Expand Down Expand Up @@ -78,7 +77,7 @@ public class GhprbTrigger extends GhprbTriggerBackwardsCompatible {
* an integer for number of threads. (default pool size: 5)
*/
private static final ExecutorService POOL = Executors.newFixedThreadPool(
SystemProperties.getInteger(GhprbTrigger.class.getName() + ".poolSize", 5)
Integer.parseInt(System.getProperty(GhprbTrigger.class.getName() + ".poolSize", "5"))
);

/**
Expand All @@ -91,7 +90,7 @@ public class GhprbTrigger extends GhprbTriggerBackwardsCompatible {
* (default: false)
*/
private static final boolean DISABLE_REGISTER_ON_STARTUP =
SystemProperties.getBoolean(GhprbTrigger.class.getName() + ".disableRegisterOnStartup", false);
Boolean.parseBoolean(System.getProperty(GhprbTrigger.class.getName() + ".disableRegisterOnStartup", "false"));

private final String adminlist;

Expand Down Expand Up @@ -331,7 +330,7 @@ public void start(Job<?, ?> project, boolean newInstance) {
new String[] {String.valueOf(DISABLE_REGISTER_ON_STARTUP)});
if (GhprbTrigger.getDscp().getManageWebhooks() && (newInstance || !DISABLE_REGISTER_ON_STARTUP)) {
final String[] params = {
String.valueOf(SystemProperties.getInteger(GhprbTrigger.class.getName() + ".poolSize", 5))
String.valueOf(System.getProperty(GhprbTrigger.class.getName() + ".poolSize", "5"))
};
LOGGER.log(Level.FINEST, "Registering hook with GitHub. Thread pool size: {0}", params);
POOL.submit(new StartHookRunnable(this.repository));
Expand Down
19 changes: 15 additions & 4 deletions src/test/java/org/jenkinsci/plugins/ghprb/GhprbIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import hudson.model.ParameterValue;
import hudson.model.Run;
import net.sf.json.JSONObject;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -20,7 +19,11 @@
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;

import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -89,12 +92,17 @@ public void shouldBuildTriggersOnUpdatingNewCommitsPR() throws Exception {
@Test
public void shouldBuildTriggersOnUpdatingRetestMessagePR() throws Exception {
// GIVEN
given(ghPullRequest.getCreatedAt()).willReturn(new DateTime().toDate());
given(ghPullRequest.getCreatedAt()).willReturn(Date.from(
ZonedDateTime.now(ZoneOffset.UTC)
.toInstant()));
GhprbTestUtil.triggerRunAndWait(10, trigger, project);
assertThat(project.getBuilds().toArray().length).isEqualTo(1);

given(comment.getBody()).willReturn("retest this please");
given(comment.getUpdatedAt()).willReturn(new DateTime().plusDays(1).toDate());
given(comment.getUpdatedAt()).willReturn(Date.from(
ZonedDateTime.now(ZoneOffset.UTC)
.plus(1, ChronoUnit.DAYS)
.toInstant()));
given(comment.getUser()).willReturn(ghUser);

given(ghPullRequest.getComments()).willReturn(newArrayList(comment));
Expand All @@ -111,7 +119,10 @@ public void shouldNotBuildDisabledBuild() throws Exception {
given(commitPointer.getSha()).willReturn("sha");

given(comment.getBody()).willReturn("retest this please");
given(comment.getUpdatedAt()).willReturn(new DateTime().plusDays(1).toDate());
given(comment.getUpdatedAt()).willReturn(Date.from(
ZonedDateTime.now(ZoneOffset.UTC)
.plus(1, ChronoUnit.DAYS)
.toInstant()));
given(comment.getUser()).willReturn(ghUser);
given(ghPullRequest.getComments()).willReturn(newArrayList(comment));
given(ghPullRequest.getNumber()).willReturn(5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.plugins.git.GitSCM;
import org.joda.time.DateTime;
import org.kohsuke.github.GHCommitPointer;
import org.kohsuke.github.GHIssueState;
import org.kohsuke.github.GHPullRequest;
Expand All @@ -16,6 +15,9 @@
import org.mockito.Mock;
import org.mockito.Mockito;

import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Map;

import static com.google.common.collect.Lists.newArrayList;
Expand Down Expand Up @@ -78,7 +80,11 @@ protected void beforeTest(

given(ghRepository.getName()).willReturn("dropwizard");

GhprbTestUtil.mockPR(ghPullRequest, commitPointer, new DateTime(), new DateTime().plusDays(1));
GhprbTestUtil.mockPR(ghPullRequest,
commitPointer,
ZonedDateTime.now(ZoneOffset.UTC),
ZonedDateTime.now(ZoneOffset.UTC)
.plus(1, ChronoUnit.DAYS));

given(ghRepository.getPullRequests(eq(GHIssueState.OPEN)))
.willReturn(newArrayList(ghPullRequest))
Expand Down
29 changes: 21 additions & 8 deletions src/test/java/org/jenkinsci/plugins/ghprb/GhprbRepositoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.apache.commons.codec.binary.Hex;
import org.fest.util.Collections;
import org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus;
import org.joda.time.DateTime;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -38,6 +37,9 @@
import java.io.IOException;
import java.net.URL;
import java.net.URLEncoder;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
Expand Down Expand Up @@ -519,8 +521,14 @@ public void testCheckMethodWhenPrWasUpdatedWithNonKeyPhrase() throws Exception {
mockCommitList();
GhprbBuilds builds = mockBuilds();

Date later = new DateTime().plusHours(3).toDate();
Date tomorrow = new DateTime().plusDays(1).toDate();
Date later = Date.from(
ZonedDateTime.now(ZoneOffset.UTC)
.plus(3, ChronoUnit.HOURS)
.toInstant());
Date tomorrow = Date.from(
ZonedDateTime.now(ZoneOffset.UTC)
.plus(1, ChronoUnit.DAYS)
.toInstant());


given(ghRepository.getPullRequests(eq(GHIssueState.OPEN))).willReturn(ghPullRequests);
Expand Down Expand Up @@ -616,8 +624,13 @@ private List<GHPullRequest> createListWithMockPR() throws IOException {
public void testCheckMethodWhenPrWasUpdatedWithRetestPhrase() throws Exception {
// GIVEN
List<GHPullRequest> ghPullRequests = createListWithMockPR();
Date now = new Date();
Date tomorrow = new DateTime().plusDays(1).toDate();
Date now = Date.from(
ZonedDateTime.now(ZoneOffset.UTC)
.toInstant());
Date tomorrow = Date.from(
ZonedDateTime.now(ZoneOffset.UTC)
.plus(1, ChronoUnit.DAYS)
.toInstant());

mockHeadAndBase();
mockCommitList();
Expand Down Expand Up @@ -665,7 +678,7 @@ public void testCheckMethodWhenPrWasUpdatedWithRetestPhrase() throws Exception {
verifyNoMoreInteractions(ghRepository);

verify(ghPullRequest, times(2)).getTitle();
verify(ghPullRequest, times(5)).getUser();
verify(ghPullRequest, times(6)).getUser();
verify(ghPullRequest, times(2)).getMergeable(); // Call to Github API
verify(ghPullRequest, times(9)).getHead();
verify(ghPullRequest, times(7)).getBase();
Expand All @@ -676,7 +689,7 @@ public void testCheckMethodWhenPrWasUpdatedWithRetestPhrase() throws Exception {
verify(ghPullRequest, times(2)).getLabels();

verify(ghPullRequest, times(1)).getId();
verify(ghPullRequest, times(1)).getComments();
verify(ghPullRequest, times(2)).getComments();
verify(ghPullRequest, times(4)).listCommits();

verify(ghPullRequest, times(2)).getBody();
Expand All @@ -702,7 +715,7 @@ public void testCheckMethodWhenPrWasUpdatedWithRetestPhrase() throws Exception {

verify(ghUser, times(1)).getEmail(); // Call to Github API
verify(ghUser, times(2)).getLogin();
verify(ghUser, times(2)).getName();
verify(ghUser, times(3)).getName();
verifyNoMoreInteractions(ghUser);

verify(builds, times(2)).build(any(GhprbPullRequest.class), any(GHUser.class), any(String.class));
Expand Down
Loading