-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c784d7b
Showing
15 changed files
with
885 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.idea/ | ||
bin/ | ||
target/ | ||
work/ | ||
*.iml |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.jenkins-ci.plugins</groupId> | ||
<artifactId>plugin</artifactId> | ||
<version>3.56</version> | ||
<relativePath /> | ||
</parent> | ||
<groupId>io.jenkins.plugins</groupId> | ||
<artifactId>github-checks-api</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>hpi</packaging> | ||
<properties> | ||
<jenkins.version>2.164.1</jenkins.version> | ||
<java.level>8</java.level> | ||
<jjwt.version>0.10.5</jjwt.version> | ||
</properties> | ||
<name>Jenkins GitHub Checks API plugin</name> | ||
<licenses> | ||
<license> | ||
<name>MIT License</name> | ||
<url>https://opensource.org/licenses/MIT</url> | ||
</license> | ||
</licenses> | ||
<!-- Assuming you want to host on @jenkinsci: | ||
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url> | ||
<scm> | ||
<connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection> | ||
<developerConnection>scm:git:[email protected]:jenkinsci/${project.artifactId}-plugin.git</developerConnection> | ||
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url> | ||
</scm> | ||
--> | ||
<repositories> | ||
<repository> | ||
<id>repo.jenkins-ci.org</id> | ||
<url>https://repo.jenkins-ci.org/public/</url> | ||
</repository> | ||
</repositories> | ||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>repo.jenkins-ci.org</id> | ||
<url>https://repo.jenkins-ci.org/public/</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
<dependencies> | ||
<!-- <dependency>--> | ||
<!-- <groupId>org.jenkins-ci.plugins</groupId>--> | ||
<!-- <artifactId>github-api</artifactId>--> | ||
<!-- <version>1.106</version>--> | ||
<!-- </dependency>--> | ||
<dependency> | ||
<groupId>org.kohsuke</groupId> | ||
<artifactId>github-api</artifactId> | ||
<version>1.108</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>4.5.12</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.coravy.hudson.plugins.github</groupId> | ||
<artifactId>github</artifactId> | ||
<version>1.29.5</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jsonwebtoken</groupId> | ||
<artifactId>jjwt-api</artifactId> | ||
<version>${jjwt.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jsonwebtoken</groupId> | ||
<artifactId>jjwt-impl</artifactId> | ||
<version>${jjwt.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jsonwebtoken</groupId> | ||
<artifactId>jjwt-jackson</artifactId> | ||
<version>${jjwt.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
</dependencies> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>3.9</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.6</version> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
</project> |
74 changes: 74 additions & 0 deletions
74
src/main/java/io/jenkins/plugins/CheckGHEventSubscriber.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package io.jenkins.plugins; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import javax.annotation.Nullable; | ||
|
||
import org.kohsuke.github.GHEvent; | ||
import org.jenkinsci.plugins.github.extension.GHEventsSubscriber; | ||
import org.jenkinsci.plugins.github.extension.GHSubscriberEvent; | ||
import hudson.Extension; | ||
import hudson.model.Item; | ||
|
||
import static com.google.common.collect.Sets.immutableEnumSet; | ||
|
||
@Extension | ||
public class CheckGHEventSubscriber extends GHEventsSubscriber { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(CheckGHEventSubscriber.class.getName()); | ||
|
||
private List<GHSubscriberEvent> checkSuiteEvents = new LinkedList<>(); | ||
private List<GHSubscriberEvent> checkRunEvents = new LinkedList<>(); | ||
|
||
public List<GHSubscriberEvent> getCheckSuiteEvents() { | ||
return checkSuiteEvents; | ||
} | ||
|
||
public List<GHSubscriberEvent> getCheckRunEvents() { | ||
return checkRunEvents; | ||
} | ||
|
||
public static CheckGHEventSubscriber getInstance() { | ||
return GHEventsSubscriber.all().get(CheckGHEventSubscriber.class); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
protected boolean isApplicable(@Nullable Item project) { | ||
return true; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @return set with CHECK_SUITE and CHECK_RUN event | ||
*/ | ||
@Override | ||
protected Set<GHEvent> events() { | ||
return immutableEnumSet(GHEvent.CHECK_RUN, GHEvent.CHECK_SUITE); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
protected void onEvent(GHSubscriberEvent event) { | ||
switch (event.getGHEvent()) { | ||
case CHECK_SUITE: | ||
LOGGER.log(Level.FINE, "Received Check Run Event..."); | ||
checkSuiteEvents.add(event); | ||
break; | ||
case CHECK_RUN: | ||
LOGGER.log(Level.FINE, "Received Check Suite Event..."); | ||
checkRunEvents.add(event); | ||
break; | ||
default: | ||
throw new IllegalStateException("Unexpected value: " + event); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package io.jenkins.plugins; | ||
|
||
import javax.annotation.CheckForNull; | ||
|
||
import hudson.ExtensionPoint; | ||
import hudson.model.Run; | ||
import jenkins.model.RunAction2; | ||
|
||
import io.jenkins.plugins.extension.CheckRunSource; | ||
|
||
public class CheckRunAction implements RunAction2, ExtensionPoint { | ||
|
||
private transient Run<?, ?> owner; | ||
|
||
private long checkRunId; | ||
private CheckRunSource source; | ||
|
||
public CheckRunAction(final long id, final CheckRunSource source) { | ||
this.checkRunId = id; | ||
this.source = source; | ||
} | ||
|
||
public long getCheckRunId() { | ||
return checkRunId; | ||
} | ||
|
||
public CheckRunSource getSource() { | ||
return source; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void onAttached(final Run<?, ?> run) { | ||
owner = run; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void onLoad(final Run<?, ?> run) { | ||
owner = run; | ||
} | ||
|
||
/** | ||
* Returns owner of this action | ||
* | ||
* @return Owner {@link Run} of this action | ||
*/ | ||
public Run<?, ?> getOwner() { | ||
return owner; | ||
} | ||
|
||
@CheckForNull | ||
@Override | ||
public String getIconFileName() { | ||
return null; | ||
} | ||
|
||
@CheckForNull | ||
@Override | ||
public String getDisplayName() { | ||
return null; | ||
} | ||
|
||
@CheckForNull | ||
@Override | ||
public String getUrlName() { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package io.jenkins.plugins; | ||
|
||
import org.kohsuke.stapler.DataBoundSetter; | ||
import org.kohsuke.stapler.QueryParameter; | ||
import hudson.Extension; | ||
import hudson.Util; | ||
import hudson.util.FormValidation; | ||
import jenkins.model.GlobalConfiguration; | ||
|
||
@Extension | ||
public final class GitHubAppConfig extends GlobalConfiguration { | ||
|
||
private static final String DEFAULT_APP_TITLE = "JENKINS"; | ||
private static final String DEFAULT_APP_ID = "0"; | ||
private static final String DEFAULT_KEY = "KEY"; | ||
|
||
private String appTitle = DEFAULT_APP_TITLE; | ||
private String appId = DEFAULT_APP_ID; | ||
private String key = DEFAULT_KEY; | ||
|
||
public GitHubAppConfig() { | ||
load(); | ||
} | ||
|
||
public static GitHubAppConfig getInstance() { | ||
return GlobalConfiguration.all().get(GitHubAppConfig.class); | ||
} | ||
|
||
public String getAppTitle() { | ||
return appTitle; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setAppTitle(@QueryParameter final String appTitle) { | ||
this.appTitle = appTitle; | ||
save(); | ||
} | ||
|
||
public String getAppId() { | ||
return appId; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setAppId(@QueryParameter final String appId) { | ||
this.appId = appId; | ||
save(); | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setKey(@QueryParameter final String key) { | ||
this.key = key; | ||
save(); | ||
} | ||
|
||
public FormValidation doCheckAppTitle(@QueryParameter String appTitle) { | ||
if (Util.fixEmptyAndTrim(appTitle) == null) | ||
return FormValidation.error("Invalid title"); | ||
return FormValidation.ok(); | ||
} | ||
|
||
public FormValidation doCheckAppId(@QueryParameter String appId) { | ||
try { | ||
Long.parseLong(appId); | ||
} catch (NumberFormatException e) { | ||
return FormValidation.error("Invalid id"); | ||
} | ||
return FormValidation.ok(); | ||
} | ||
|
||
public FormValidation doCheckKey(@QueryParameter String key) { | ||
if (Util.fixEmptyAndTrim(key) == null) | ||
return FormValidation.error("Invalid key"); | ||
return FormValidation.ok(); | ||
} | ||
} |
Oops, something went wrong.