forked from masanobuimai/emotional-jenkins-plugin
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 06606e3
Showing
9 changed files
with
189 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,40 @@ | ||
<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>1.399</version><!-- which version of Jenkins is this plugin built against? --> | ||
</parent> | ||
|
||
<groupId>org.jenkins-ci.plugins</groupId> | ||
<artifactId>emotional-jenkins-plugin</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>hpi</packaging> | ||
<developers> | ||
<developer> | ||
<id>masanobuimai</id> | ||
<name>Masanobu Imai</name> | ||
</developer> | ||
</developers> | ||
|
||
<scm> | ||
<connection>scm:git:ssh://github.com/jenkinsci/emotioanl-jenkins-plugin.git</connection> | ||
<developerConnection>scm:git:ssh://git@github.com/jenkinsci/emotioanl-jenkins-plugin.git</developerConnection> | ||
<url>https://github.com/jenkinsci/emotioanl-jenkins-plugin</url> | ||
</scm> | ||
|
||
<!-- get every artifact through maven.glassfish.org, which proxies all the artifacts that we need --> | ||
<repositories> | ||
<repository> | ||
<id>m.g.o-public</id> | ||
<url>http://maven.glassfish.org/content/groups/public/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>m.g.o-public</id> | ||
<url>http://maven.glassfish.org/content/groups/public/</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
</project> |
21 changes: 21 additions & 0 deletions
21
src/main/java/org/jenkinsci/plugins/emotional_jenkins/EmotionalJenkinsAction.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,21 @@ | ||
package org.jenkinsci.plugins.emotional_jenkins; | ||
|
||
import hudson.model.ProminentProjectAction; | ||
import hudson.model.Result; | ||
|
||
public final class EmotionalJenkinsAction implements ProminentProjectAction { | ||
|
||
private Result result; | ||
|
||
public EmotionalJenkinsAction() {} | ||
|
||
public EmotionalJenkinsAction(Result result) { | ||
this.result = result; | ||
} | ||
|
||
public String getIconFileName() { return null; } | ||
public String getDisplayName() { return ""; } | ||
public String getUrlName() { return ""; } | ||
|
||
public Result getResult() { return result; } | ||
} |
86 changes: 86 additions & 0 deletions
86
src/main/java/org/jenkinsci/plugins/emotional_jenkins/EmotionalJenkinsPublisher.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,86 @@ | ||
package org.jenkinsci.plugins.emotional_jenkins; | ||
|
||
import hudson.Extension; | ||
import hudson.Launcher; | ||
import hudson.model.*; | ||
import hudson.tasks.BuildStepDescriptor; | ||
import hudson.tasks.BuildStepMonitor; | ||
import hudson.tasks.Notifier; | ||
import hudson.tasks.Publisher; | ||
import net.sf.json.JSONObject; | ||
import org.kohsuke.stapler.StaplerRequest; | ||
|
||
import java.io.IOException; | ||
|
||
public class EmotionalJenkinsPublisher extends Notifier { | ||
|
||
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { | ||
/* | ||
DESCRIPTOR.counter++; | ||
int value = DESCRIPTOR.counter % 5; | ||
switch (value) { | ||
case 0: | ||
build.setResult(Result.FAILURE); | ||
break; | ||
case 1: | ||
build.setResult(Result.UNSTABLE); | ||
break; | ||
case 2: | ||
build.setResult(Result.ABORTED); | ||
break; | ||
case 3: | ||
build.setResult(Result.NOT_BUILT); | ||
break; | ||
default: | ||
} | ||
*/ | ||
|
||
build.getActions().add(new EmotionalJenkinsAction(build.getResult())); | ||
return true; | ||
} | ||
|
||
public Action getProjectAction(Project project) { | ||
return new EmotionalJenkinsAction(); | ||
} | ||
|
||
public BuildStepMonitor getRequiredMonitorService() { | ||
return BuildStepMonitor.BUILD; | ||
} | ||
|
||
@Override | ||
public BuildStepDescriptor<Publisher> getDescriptor() { | ||
return DESCRIPTOR; | ||
} | ||
|
||
@Extension | ||
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl(); | ||
|
||
public static final class DescriptorImpl extends BuildStepDescriptor<Publisher> { | ||
// public static int counter = 0; | ||
|
||
DescriptorImpl() { | ||
super(EmotionalJenkinsPublisher.class); | ||
load(); | ||
} | ||
|
||
public String getDisplayName() { | ||
return "Emotional Jenkins"; | ||
} | ||
|
||
@Override | ||
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { | ||
save(); | ||
return super.configure(req, formData); | ||
} | ||
|
||
@Override | ||
public Publisher newInstance(StaplerRequest req, JSONObject formData) throws FormException { | ||
return new EmotionalJenkinsPublisher(); | ||
} | ||
|
||
@Override | ||
public boolean isApplicable(Class<? extends AbstractProject> jobType) { | ||
return true; | ||
} | ||
} | ||
} |
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,6 @@ | ||
<!-- | ||
This view is used to render the installed plugins page. | ||
--> | ||
<div> | ||
This plugin is a sample to explain how to write a Jenkins plugin. | ||
</div> |
18 changes: 18 additions & 0 deletions
18
...esources/org/jenkinsci/plugins/emotional_jenkins/EmotionalJenkinsAction/floatingBox.jelly
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,18 @@ | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt" xmlns:local="local"> | ||
<j:set var="result" value="${it.lastBuild.result.toString()}"/> | ||
<script> | ||
Element.setStyle($('main-table'), { | ||
<j:choose> | ||
<j:when test='${result.equals("UNSTABLE")}'> | ||
'background-image': 'url(${rootURL}/plugin/emotional-jenkins-plugin/images/sad-jenkins.png)' | ||
</j:when> | ||
<j:when test='${result.equals("FAILURE")}'> | ||
'background-image': 'url(${rootURL}/plugin/emotional-jenkins-plugin/images/angry-jenkins.png)' | ||
</j:when> | ||
<j:otherwise> | ||
'background-image': 'url(${rootURL}/plugin/emotional-jenkins-plugin/images/jenkins.png)' | ||
</j:otherwise> | ||
</j:choose> | ||
}); | ||
</script> | ||
</j:jelly> |
18 changes: 18 additions & 0 deletions
18
...in/resources/org/jenkinsci/plugins/emotional_jenkins/EmotionalJenkinsAction/summary.jelly
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,18 @@ | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt" xmlns:local="local"> | ||
<j:set var="result" value="${it.result.toString()}"/> | ||
<script> | ||
Element.setStyle($('main-table'), { | ||
<j:choose> | ||
<j:when test='${result.equals("UNSTABLE")}'> | ||
'background-image': 'url(${rootURL}/plugin/emotional-jenkins-plugin/images/sad-jenkins.png)' | ||
</j:when> | ||
<j:when test='${result.equals("FAILURE")}'> | ||
'background-image': 'url(${rootURL}/plugin/emotional-jenkins-plugin/images/angry-jenkins.png)' | ||
</j:when> | ||
<j:otherwise> | ||
'background-image': 'url(${rootURL}/plugin/emotional-jenkins-plugin/images/jenkins.png)' | ||
</j:otherwise> | ||
</j:choose> | ||
}); | ||
</script> | ||
</j:jelly> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.