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

Add server url to global configuration #56

Open
wants to merge 3 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ target
.settings
bin
work
/nbproject/
54 changes: 27 additions & 27 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<modelVersion>4.0.0</modelVersion>

<!-- change to this parent to compare building this plugin for Hudson -->
<!--
<!--
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>hudson-plugin-parent</artifactId>
<version>2.0.0</version>
</parent>
-->
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>hudson-plugin-parent</artifactId>
<version>2.0.0</version>
</parent>
-->

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -19,11 +19,11 @@

<!-- keeping original groupId -->
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>hipchat</artifactId>
<packaging>hpi</packaging>
<version>0.1.5-SNAPSHOT</version>
<name>Jenkins HipChat Plugin</name>
<description>A Build status publisher that notifies channels on a HipChat server</description>
<artifactId>hipchat</artifactId>
<packaging>hpi</packaging>
<version>0.1.5-SNAPSHOT</version>
<name>Jenkins HipChat Plugin</name>
<description>A Build status publisher that notifies channels on a HipChat server</description>
<url>http://wiki.jenkins-ci.org/display/JENKINS/HipChat+Plugin</url>

<properties>
Expand All @@ -32,11 +32,11 @@
</properties>

<licenses>
<license>
<name>MIT license</name>
<comments>All source code is under the MIT license.</comments>
</license>
</licenses>
<license>
<name>MIT license</name>
<comments>All source code is under the MIT license.</comments>
</license>
</licenses>

<distributionManagement>
<repository>
Expand All @@ -51,12 +51,12 @@
<url>https://github.com/jlewallen/jenkins-hipchat-plugin</url>
</scm>

<dependencies>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependencies>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -83,11 +83,11 @@
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<configuration>
<disabledTestInjection>true</disabledTestInjection>
</configuration>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<configuration>
<disabledTestInjection>true</disabledTestInjection>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Expand Down
52 changes: 36 additions & 16 deletions src/main/java/jenkins/plugins/hipchat/ActiveNotifier.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
package jenkins.plugins.hipchat;

import hudson.Util;
import hudson.model.*;
import hudson.scm.ChangeLogSet;
import hudson.scm.ChangeLogSet.AffectedFile;
import hudson.scm.ChangeLogSet.Entry;
import org.apache.commons.lang.StringUtils;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;

import org.apache.commons.lang.StringUtils;

import hudson.Util;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.CauseAction;
import hudson.model.Result;
import hudson.model.Run;
import hudson.scm.ChangeLogSet;
import hudson.scm.ChangeLogSet.AffectedFile;
import hudson.scm.ChangeLogSet.Entry;

@SuppressWarnings("rawtypes")
public class ActiveNotifier implements FineGrainedNotifier {
public class ActiveNotifier implements FineGrainedNotifier
{

private static final Logger logger = Logger.getLogger(HipChatListener.class.getName());

Expand Down Expand Up @@ -81,7 +87,7 @@ String getChanges(AbstractBuild r) {
List<Entry> entries = new LinkedList<Entry>();
Set<AffectedFile> files = new HashSet<AffectedFile>();
for (Object o : changeSet.getItems()) {
Entry entry = (Entry) o;
Entry entry = (Entry)o;
logger.info("Entry " + o);
entries.add(entry);
files.addAll(entry.getAffectedFiles());
Expand Down Expand Up @@ -121,7 +127,9 @@ String getBuildStatusMessage(AbstractBuild r) {
return message.appendOpenLink().toString();
}

public static class MessageBuilder {
public static class MessageBuilder
{

private StringBuffer message;
private HipChatNotifier notifier;
private AbstractBuild build;
Expand All @@ -145,12 +153,24 @@ static String getStatusMessage(AbstractBuild r) {
Result result = r.getResult();
Run previousBuild = r.getProject().getLastBuild().getPreviousBuild();
Result previousResult = (previousBuild != null) ? previousBuild.getResult() : Result.SUCCESS;
if (result == Result.SUCCESS && previousResult == Result.FAILURE) return "Back to normal";
if (result == Result.SUCCESS) return "Success";
if (result == Result.FAILURE) return "<b>FAILURE</b>";
if (result == Result.ABORTED) return "ABORTED";
if (result == Result.NOT_BUILT) return "Not built";
if (result == Result.UNSTABLE) return "Unstable";
if (result == Result.SUCCESS && previousResult == Result.FAILURE) {
return "Back to normal";
}
if (result == Result.SUCCESS) {
return "Success";
}
if (result == Result.FAILURE) {
return "<b>FAILURE</b>";
}
if (result == Result.ABORTED) {
return "ABORTED";
}
if (result == Result.NOT_BUILT) {
return "Not built";
}
if (result == Result.UNSTABLE) {
return "Unstable";
}
return "Unknown";
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/jenkins/plugins/hipchat/DisabledNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import hudson.model.AbstractBuild;

@SuppressWarnings("rawtypes")
public class DisabledNotifier implements FineGrainedNotifier {
public class DisabledNotifier implements FineGrainedNotifier
{

public void started(AbstractBuild r) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import hudson.model.AbstractBuild;

public interface FineGrainedNotifier {
public interface FineGrainedNotifier
{

@SuppressWarnings("rawtypes")
void started(AbstractBuild r);
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/jenkins/plugins/hipchat/HipChatListener.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package jenkins.plugins.hipchat;

import java.util.Map;
import java.util.logging.Logger;

import hudson.Extension;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
Expand All @@ -8,12 +11,10 @@
import hudson.model.listeners.RunListener;
import hudson.tasks.Publisher;

import java.util.Map;
import java.util.logging.Logger;

@Extension
@SuppressWarnings("rawtypes")
public class HipChatListener extends RunListener<AbstractBuild> {
public class HipChatListener extends RunListener<AbstractBuild>
{

private static final Logger logger = Logger.getLogger(HipChatListener.class.getName());

Expand Down Expand Up @@ -50,7 +51,7 @@ FineGrainedNotifier getNotifier(AbstractProject project) {
Map<Descriptor<Publisher>, Publisher> map = project.getPublishersList().toMap();
for (Publisher publisher : map.values()) {
if (publisher instanceof HipChatNotifier) {
return new ActiveNotifier((HipChatNotifier) publisher);
return new ActiveNotifier((HipChatNotifier)publisher);
}
}
return new DisabledNotifier();
Expand Down
Loading