Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
masanobuimai committed Aug 5, 2011
0 parents commit 06606e3
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 0 deletions.
40 changes: 40 additions & 0 deletions pom.xml
@@ -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>
@@ -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; }
}
@@ -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;
}
}
}
6 changes: 6 additions & 0 deletions src/main/resources/index.jelly
@@ -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>
@@ -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>
@@ -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>
Binary file added src/main/webapp/images/angry-jenkins.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/webapp/images/jenkins.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/webapp/images/sad-jenkins.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 06606e3

Please sign in to comment.