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 to use github-api 1.114.2 #788

Closed
Closed
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
11 changes: 6 additions & 5 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,15 @@
<!-- <property name="fileExtensions" value="java"/> -->
<!-- </module> -->

<module name="SuppressionCommentFilter"/>
<module name="LineLength">
<property name="max" value="140" />
</module>

<module name="TreeWalker">

<module name="FileContentsHolder"/>
<module name="SuppressionCommentFilter"/>

<!-- <module name="FileContentsHolder"/>-->

<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
Expand Down Expand Up @@ -116,9 +120,6 @@

<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="LineLength">
<property name="max" value="140" />
</module>
<module name="MethodLength"/>

<!-- Checks for whitespace -->
Expand Down
122 changes: 38 additions & 84 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>4.2</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -50,13 +50,15 @@
<properties>
<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>
<powermock.version>1.6.2</powermock.version>
<java.level>7</java.level>
<jenkins.version>2.164.3</jenkins.version>
<powermock.version>1.7.4</powermock.version>
<java.level>8</java.level>
<findbugs.failOnError>false</findbugs.failOnError>
<checkstyle.version>6.7</checkstyle.version>
<checkstyle.plugin.version>2.17</checkstyle.plugin.version>
<checkstyle.version>8.33</checkstyle.version>
<checkstyle.plugin.version>3.1.1</checkstyle.plugin.version>
<!-- this plugin use jenkins.utils.SystemProperties, which is marked "NoExternalUse" -->
<!-- See https://issues.jenkins-ci.org/browse/JENKINS-52704 -->
<access-modifier-checker.skip>true</access-modifier-checker.skip>
</properties>

<!--
Expand All @@ -73,86 +75,34 @@

<dependencies>

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

<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>symbol-annotation</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>annotation-indexer</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1.25</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.11</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.10</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-classworlds</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>bouncycastle-api</artifactId>
<version>2.16.1</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.31.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>github-api</artifactId>
<version>1.92</version>
<version>1.114.2</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git</artifactId>
<version>3.3.1</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>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -182,7 +132,6 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>token-macro</artifactId>
<version>2.1</version>
<optional>true</optional>
</dependency>
<dependency>
Expand All @@ -194,31 +143,51 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>2.1.14</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plain-credentials</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.9</version>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.164.x</artifactId>
<version>9</version>
<scope>import</scope>
<type>pom</type>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<version>3.0.0-M4</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.16</version>
<version>3.0.0-M4</version>
</dependency>
</dependencies>
</plugin>
Expand Down Expand Up @@ -256,15 +225,6 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand Down Expand Up @@ -302,13 +262,7 @@
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
<repository>
<id>jgit-repository</id>
<name>Eclipse JGit Repository</name>
<url>http://download.eclipse.org/jgit/maven</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jenkinsci/plugins/ghprb/Ghprb.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ public String checkBlackListCommitAuthor(String author) {
Set<String> authors = getBlacklistedCommitAuthors();
authors.remove("");

Map<Pattern, String> skipPatterns = new HashMap<Pattern, String>();
for (String s : authors) {
s = s.trim();
if (compilePattern(s).matcher(author).matches()) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jenkinsci/plugins/ghprb/GhprbBuilds.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.model.queue.QueueTaskFuture;
import hudson.plugins.git.Revision;
import hudson.plugins.git.util.BuildData;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.ghprb.extensions.GhprbBuildStep;
Expand Down Expand Up @@ -186,7 +187,8 @@ public void onCompleted(Run<?, ?> build, TaskListener listener) {
// having two of them, and because the one we added isn't correct
// @see GhprbTrigger
for (BuildData data : build.getActions(BuildData.class)) {
if (data.getLastBuiltRevision() != null && !data.getLastBuiltRevision().getSha1String().equals(c.getCommit())) {
final Revision revision = data.getLastBuiltRevision();
if (revision != null && !revision.getSha1String().equals(c.getCommit())) {
build.getActions().remove(data);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public boolean checkSignature(String body, String signature) {
new Object[] {localSignature, expected});
return false;
}
} catch (Exception e) {
} catch (Throwable e) {
LOGGER.log(Level.SEVERE, "Couldn't match both signatures");
return false;
}
Expand All @@ -172,7 +172,7 @@ public boolean checkSignature(String body, String signature) {
private static GitHubBuilder getBuilder(Item context, String serverAPIUrl, String credentialsId) {
GitHubBuilder builder = new GitHubBuilder()
.withEndpoint(serverAPIUrl)
.withConnector(new HttpConnectorWithJenkinsProxy());
.withConnector(new HttpConnectorWithJenkinsProxy(serverAPIUrl));
String contextName = context == null ? "(Jenkins.instance)" : context.getFullDisplayName();

if (StringUtils.isEmpty(credentialsId)) {
Expand Down Expand Up @@ -285,7 +285,7 @@ public FormValidation doCreateApiToken(

GitHubBuilder builder = new GitHubBuilder()
.withEndpoint(serverAPIUrl)
.withConnector(new HttpConnectorWithJenkinsProxy());
.withConnector(new HttpConnectorWithJenkinsProxy(serverAPIUrl));

if (StringUtils.isEmpty(credentialsId)) {
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
Expand Down
34 changes: 19 additions & 15 deletions src/main/java/org/jenkinsci/plugins/ghprb/GhprbPullRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ private void checkBlackListLabels() {
LOGGER.log(Level.INFO,
"Found label {0} in ignore list, pull request will be ignored.",
label.getName());
shouldRun = false;
synchronized (this) {
shouldRun = false;
}
}
}
} catch (Error e) {
Expand All @@ -262,7 +264,9 @@ private void checkWhiteListLabels() {

if (!containsWhiteListLabel) {
LOGGER.log(Level.INFO, "Can't find any of whitelist label.");
shouldRun = false;
synchronized (this) {
shouldRun = false;
}
}
} catch (Error e) {
LOGGER.log(Level.SEVERE, "Failed to read whitelist labels", e);
Expand Down Expand Up @@ -330,20 +334,20 @@ public void check(GHIssueComment comment) {
private void updatePR(GHPullRequest ghpr, GHIssueComment comment, boolean isWebhook) {
// Get the updated time
try {
Date lastUpdateTime = updated;
Date updatedDate = comment != null ? comment.getUpdatedAt() : ghpr.getUpdatedAt();
// Don't log unless it was actually updated
if (updated == null || updated.compareTo(updatedDate) < 0) {
String user = comment != null ? comment.getUser().getName() : ghpr.getUser().getName();
LOGGER.log(
Level.INFO,
"Pull request #{0} was updated/initialized on {1} at {2} by {3} ({4})",
new Object[] {this.id, this.repo.getName(), updatedDate, user,
comment != null ? "comment" : "PR update"}
);
}

synchronized (this) {
Date lastUpdateTime = updated;
Date updatedDate = comment != null ? comment.getUpdatedAt() : ghpr.getUpdatedAt();
// Don't log unless it was actually updated
if (updated == null || updated.compareTo(updatedDate) < 0) {
String user = comment != null ? comment.getUser().getName() : ghpr.getUser().getName();
LOGGER.log(
Level.INFO,
"Pull request #{0} was updated/initialized on {1} at {2} by {3} ({4})",
new Object[] {this.id, this.repo.getName(), updatedDate, user,
comment != null ? "comment" : "PR update"}
);
}

boolean wasUpdated = setUpdated(updatedDate);

// Update the PR object with the new pull request object if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public void perform(
) throws InterruptedException, IOException {
listener = taskListener;
Job<?, ?> project = run.getParent();
if (run.getResult().isWorseThan(Result.SUCCESS)) {
Result result = run.getResult();
if (result != null && result.isWorseThan(Result.SUCCESS)) {
listener.getLogger().println("Build did not succeed, merge will not be run");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private boolean initGhRepository() {
}

try {
if (gitHub.getRateLimit().remaining == 0) {
if (gitHub.getRateLimit().getRemaining() == 0) {
LOGGER.log(Level.INFO, "Exceeded rate limit for repository");
return false;
}
Expand Down
Loading