diff --git a/pom.xml b/pom.xml
index f8dfca6..244e436 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,11 +4,11 @@
org.jenkins-ci.plugins
plugin
- 1.580.3
+ 1.596.2
mantis
- 0.27-SNAPSHOT
+ 0.28-SNAPSHOT
hpi
Jenkins Mantis plugin
Integrates Jenkins to Mantis
@@ -20,6 +20,11 @@
Seiji Sogabe
s.sogabe@gmail.com
+
+ LFA
+ Fabre Lucas
+ l.fabre@amesys.fr
+
diff --git a/src/main/java/hudson/plugins/mantis/MantisIssueRegister.java b/src/main/java/hudson/plugins/mantis/MantisIssueRegister.java
index d5f5c90..0fa3f6b 100644
--- a/src/main/java/hudson/plugins/mantis/MantisIssueRegister.java
+++ b/src/main/java/hudson/plugins/mantis/MantisIssueRegister.java
@@ -10,6 +10,7 @@
import hudson.model.Result;
import hudson.plugins.mantis.model.MantisCategory;
import hudson.plugins.mantis.model.MantisIssue;
+import hudson.plugins.mantis.model.MantisIssueStatus;
import hudson.plugins.mantis.model.MantisProject;
import hudson.plugins.mantis.model.MantisViewState;
import hudson.plugins.mantis.scripts.JellyScriptContent;
@@ -123,12 +124,13 @@ private MantisIssue createIssue(AbstractBuild, ?> build, BuildListener listene
String summary = summary(build);
String description = new JellyScriptContent().getContent(build, build.getResult());
MantisViewState viewState;
+
if (isKeepTicketPrivate()) {
viewState = MantisViewState.PUBLIC;
} else {
viewState = MantisViewState.PRIVATE;
}
- return new MantisIssue(project, category, summary, description, viewState);
+ return new MantisIssue(project, category, summary, description,viewState,"new");
}
private String summary(AbstractBuild, ?> build) {
diff --git a/src/main/java/hudson/plugins/mantis/MantisIssueUpdater.java b/src/main/java/hudson/plugins/mantis/MantisIssueUpdater.java
index cccba6f..23b2a36 100644
--- a/src/main/java/hudson/plugins/mantis/MantisIssueUpdater.java
+++ b/src/main/java/hudson/plugins/mantis/MantisIssueUpdater.java
@@ -11,6 +11,7 @@
import hudson.tasks.Publisher;
import hudson.tasks.Recorder;
import java.io.IOException;
+import java.util.logging.Level;
import net.sf.json.JSONObject;
@@ -24,24 +25,117 @@
*/
public final class MantisIssueUpdater extends Recorder {
- private final boolean keepNotePrivate;
+ private final boolean keepNotePrivate;
- private final boolean recordChangelog;
+ private boolean addChangeLog;
+
+ private final boolean resolvedFilter;
+
+ private boolean NewNoteWithChangeLog;
+
+ private boolean InvertSecondStateNote;
+
+ private boolean ModeNewChangeLogNote;
+
+ private boolean ModeAddChangeLogNote;
+
+ private boolean ModeNewChangeLogNoteInvertedStatus;
+
+
+
+
@DataBoundConstructor
- public MantisIssueUpdater(final boolean keepNotePrivate, final boolean recordChangelog) {
+ public MantisIssueUpdater(
+ boolean keepNotePrivate,
+ boolean addChangeLog,
+ boolean resolvedFilter,
+ boolean NewNoteWithChangeLog,
+ boolean InvertSecondStateNote,
+ boolean ModeNewChangeLogNote,
+ boolean ModeAddChangeLogNote,
+ boolean ModeNewChangeLogNoteInvertedStatus
+
+ )
+ {
this.keepNotePrivate = keepNotePrivate;
- this.recordChangelog = recordChangelog;
+ this.resolvedFilter = resolvedFilter;
+ //----------------------------------------
+ this.addChangeLog = addChangeLog;
+ this.NewNoteWithChangeLog = NewNoteWithChangeLog;
+ this.InvertSecondStateNote = InvertSecondStateNote;
+ this.ModeNewChangeLogNote = ModeNewChangeLogNote;
+ this.ModeAddChangeLogNote = ModeAddChangeLogNote;
+ this.ModeNewChangeLogNoteInvertedStatus = ModeNewChangeLogNoteInvertedStatus;
+ SetMode();
+ }
+
+
+ public boolean isModeNewChangeLogNote(){
+ return ModeNewChangeLogNote;
+
+ }
+ public boolean isModeAddChangeLogNote(){
+ return ModeAddChangeLogNote;
+
+ }
+ public boolean isModeNewChangeLogNoteInvertedStatus(){
+ return ModeNewChangeLogNoteInvertedStatus;
+
}
-
public boolean isKeepNotePrivate() {
return keepNotePrivate;
}
- public boolean isRecordChangelog() {
- return recordChangelog;
+ public boolean isAddChangeLog() {
+ return addChangeLog;
+ }
+ public boolean isResolvedFilter() {
+ return resolvedFilter;
+ }
+
+ public boolean isNewNoteWithChangeLog() {
+ return NewNoteWithChangeLog;
}
+ public boolean isInvertSecondStateNote() {
+ return InvertSecondStateNote;
+ }
+
+ public void SetMode(){
+ this.addChangeLog = false;
+ this.NewNoteWithChangeLog = false;
+ this.InvertSecondStateNote = false;
+
+ // Exclusive Select if Mode 1 & Mode 2 are Selected only M1 be active
+ if(ModeAddChangeLogNote == true){
+ //Set other mod to false
+ this.ModeNewChangeLogNote = false;
+ this.ModeNewChangeLogNoteInvertedStatus = false;
+
+ this.addChangeLog = true;
+ }
+ // Exclusive Select if Mode 1 & Mode 2 are Selected only M1 be active
+ if(ModeNewChangeLogNote == true){
+ //Set other mod to false
+ this.ModeAddChangeLogNote = false;
+ this.ModeNewChangeLogNoteInvertedStatus = false;
+
+ this.addChangeLog = true;
+ this.NewNoteWithChangeLog = true;
+ }
+ // Exclusive Select if Mode 2 & Mode 3 are Selected only M2 be active
+ if(ModeNewChangeLogNoteInvertedStatus == true){
+ //Set other mod to false
+ this.ModeAddChangeLogNote = false;
+ this.ModeNewChangeLogNote = false;
+
+ this.addChangeLog = true;
+ this.NewNoteWithChangeLog = true;
+ this.InvertSecondStateNote = true;
+
+ }
+ }
@Override
public BuildStepMonitor getRequiredMonitorService() {
return BuildStepMonitor.NONE;
@@ -56,9 +150,10 @@ public boolean perform(final AbstractBuild, ?> build, final Launcher launcher,
@Extension
public static final class DescriptorImpl extends BuildStepDescriptor {
-
+
public DescriptorImpl() {
super(MantisIssueUpdater.class);
+
}
@Override
@@ -78,7 +173,10 @@ public boolean isApplicable(Class extends AbstractProject> jobType) {
@Override
public Publisher newInstance(final StaplerRequest req, final JSONObject formData) {
+ req.bindJSON(this, formData.getJSONObject("fruit"));
+ save();
return req.bindJSON(MantisIssueUpdater.class, formData);
}
+
}
}
diff --git a/src/main/java/hudson/plugins/mantis/MantisSite.java b/src/main/java/hudson/plugins/mantis/MantisSite.java
index bb676f2..9cf8bfc 100644
--- a/src/main/java/hudson/plugins/mantis/MantisSite.java
+++ b/src/main/java/hudson/plugins/mantis/MantisSite.java
@@ -9,6 +9,7 @@
import hudson.plugins.mantis.model.MantisViewState;
import hudson.plugins.mantis.soap.MantisSession;
import hudson.plugins.mantis.soap.MantisSessionFactory;
+import hudson.plugins.mantis.model.MantisIssueStatus;
import hudson.util.Secret;
import java.net.MalformedURLException;
@@ -173,24 +174,74 @@ public boolean isConnect() {
public MantisIssue getIssue(final int id) throws MantisHandlingException {
final MantisSession session = createSession();
+
+ String msglog = "LOG LFA : Appel getIssue : ";
+ LOGGER.log(Level.INFO,msglog);
+
return session.getIssue(id);
}
- public void updateIssue(final int id, final String text, final boolean keepNotePrivate)
+ public void updateIssue(final int id, final String text, String textSecondNote, final boolean keepNotePrivate, final boolean resolvedFilter, final boolean addChangeLog, final boolean InvertSecondStateNote, final boolean NewNoteWithChangeLog )
throws MantisHandlingException {
MantisViewState viewState;
- if (keepNotePrivate) {
- viewState = MantisViewState.PRIVATE;
- } else {
- viewState = MantisViewState.PUBLIC;
- }
- MantisNote note = new MantisNote(text, viewState);
-
+ viewState = MantisViewState.PUBLIC;
+
MantisSession session = createSession();
- session.addNote(id, note);
+
+
+ if (keepNotePrivate)
+ {
+ viewState = MantisViewState.PRIVATE;
+ }
+ // Try With two Args text
+ this.createNote(viewState, addChangeLog, InvertSecondStateNote, NewNoteWithChangeLog ,resolvedFilter, session, id, text, textSecondNote);
+
+
+
}
+
+ public void createNote(
+ MantisViewState viewState,
+ boolean addChangeLog,
+ boolean InvertSecondStateNote,
+ boolean NewNoteWithChangeLog,
+ boolean Resolved,
+ MantisSession session,
+ int id,
+ String text,
+ String textSecondNote)
+ throws MantisHandlingException
+ {
+
+
+
+ if(addChangeLog){
+ if (NewNoteWithChangeLog)
+ {
+ MantisViewState newNoteViewState = viewState;
+ if(InvertSecondStateNote)
+ {
+
+ newNoteViewState = MantisViewState.invertViewState(viewState);
+ }
+ //Add note with changelog
+ MantisNote noteWithChange = new MantisNote(textSecondNote, newNoteViewState);
+ session.addNote(id, noteWithChange,Resolved);
+ }
+ //Add note with changelog
+ MantisNote noteWithChange = new MantisNote(text, viewState);
+ session.addNote(id, noteWithChange,Resolved);
+ }
+ else
+ {
+ //Add note without any changelog
+ // Modif MantisNote Text if Add Changelog == false
+ MantisNote noteWithChange = new MantisNote(text, viewState);
+ session.addNote(id, noteWithChange,Resolved);
+ }
+ }
public List getProjects() throws MantisHandlingException {
final MantisSession session = createSession();
return session.getProjects();
diff --git a/src/main/java/hudson/plugins/mantis/Updater.java b/src/main/java/hudson/plugins/mantis/Updater.java
index 0100a5a..fcbdbfa 100644
--- a/src/main/java/hudson/plugins/mantis/Updater.java
+++ b/src/main/java/hudson/plugins/mantis/Updater.java
@@ -28,6 +28,8 @@ final class Updater {
private static final String CRLF = System.getProperty("line.separator");
private final MantisIssueUpdater property;
+
+ private boolean flag;
Updater(final MantisIssueUpdater property) {
this.property = property;
@@ -69,8 +71,17 @@ boolean perform(final AbstractBuild, ?> build, final BuildListener listener) {
try {
final MantisIssue issue = site.getIssue(changeSet.getId());
if (update) {
- final String text = createUpdateText(build, changeSet, rootUrl);
- site.updateIssue(changeSet.getId(), text, property.isKeepNotePrivate());
+ //Add a System flag to control Changelogs on note
+ flag = false ;
+ final String text = createUpdateText(build, changeSet, rootUrl);
+ String text2 = "" ;
+ if(property.isNewNoteWithChangeLog()){
+
+ flag = true;
+ text2 = createUpdateText(build, changeSet, rootUrl);
+
+ }
+ site.updateIssue(changeSet.getId(), text, text2, property.isKeepNotePrivate(), property.isResolvedFilter(), property.isAddChangeLog(), property.isInvertSecondStateNote(), property.isNewNoteWithChangeLog());
Utility.log(logger, Messages.Updater_Updating(changeSet.getId()));
}
issues.add(issue);
@@ -92,14 +103,23 @@ private String createUpdateText(final AbstractBuild, ?> build, final ChangeSet
final String prjName = build.getProject().getName();
final int prjNumber = build.getNumber();
final String url = rootUrl + build.getUrl();
-
+
final StringBuilder text = new StringBuilder();
+
text.append(Messages.Updater_IssueIntegrated(prjName, prjNumber, url));
text.append(CRLF).append(CRLF);
- if (property.isRecordChangelog()) {
+ if (property.isAddChangeLog() && property.isNewNoteWithChangeLog() == false )
+ {
text.append(changeSet.createChangeLog());
}
+
+ if (property.isAddChangeLog()&& flag == true)
+ {
+ text.append(changeSet.createChangeLog());
+ flag = false;
+ }
+
return text.toString();
}
diff --git a/src/main/java/hudson/plugins/mantis/model/MantisIssue.java b/src/main/java/hudson/plugins/mantis/model/MantisIssue.java
index de35f46..1262f08 100644
--- a/src/main/java/hudson/plugins/mantis/model/MantisIssue.java
+++ b/src/main/java/hudson/plugins/mantis/model/MantisIssue.java
@@ -22,6 +22,10 @@ public final class MantisIssue implements Serializable {
private MantisCategory category;
private MantisViewState viewState;
+
+ private String status;
+
+
public int getId() {
return id;
@@ -42,22 +46,30 @@ public MantisCategory getCategory() {
public MantisProject getProject() {
return project;
}
+
+ public String getStatus() {
+ return status;
+ }
- public MantisIssue(final int id, final String summary) {
+ public MantisIssue(final int id, final String summary, final String status) {
this.id = id;
this.summary = summary;
+ this.status = status;
}
public MantisViewState getViewState() {
return viewState;
}
+ /* Mantis Issue Constructor */
+
public MantisIssue(MantisProject project, MantisCategory category, String summary,
- String description, MantisViewState viewState) {
+ String description, MantisViewState viewState, String status) {
this.summary = summary;
this.description = description;
this.project = project;
this.category = category;
this.viewState = viewState;
+ this.status = status;
}
}
diff --git a/src/main/java/hudson/plugins/mantis/model/MantisIssueStatus.java b/src/main/java/hudson/plugins/mantis/model/MantisIssueStatus.java
new file mode 100644
index 0000000..13a300b
--- /dev/null
+++ b/src/main/java/hudson/plugins/mantis/model/MantisIssueStatus.java
@@ -0,0 +1,25 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package hudson.plugins.mantis.model;
+import java.io.Serializable;
+/**
+ *
+ * @author FabreLucaS
+ */
+
+/* Enum Issue Status to match Status and add a Filter */
+public enum MantisIssueStatus {
+
+ New,
+ acknowledged,
+ pending,
+ assigned,
+ inprogress,
+ resolved,
+ verified,
+ rejected,
+ closed,
+}
diff --git a/src/main/java/hudson/plugins/mantis/model/MantisNote.java b/src/main/java/hudson/plugins/mantis/model/MantisNote.java
index 9db89b3..bc0b471 100644
--- a/src/main/java/hudson/plugins/mantis/model/MantisNote.java
+++ b/src/main/java/hudson/plugins/mantis/model/MantisNote.java
@@ -14,6 +14,8 @@ public final class MantisNote implements Serializable {
private final String text;
private final MantisViewState viewState;
+
+
public String getText() {
return text;
@@ -23,6 +25,7 @@ public MantisViewState getViewState() {
return viewState;
}
+
public MantisNote(final String text, final MantisViewState viewState) {
this.text = text;
this.viewState = viewState;
diff --git a/src/main/java/hudson/plugins/mantis/model/MantisViewState.java b/src/main/java/hudson/plugins/mantis/model/MantisViewState.java
index 7c418a2..1d38467 100644
--- a/src/main/java/hudson/plugins/mantis/model/MantisViewState.java
+++ b/src/main/java/hudson/plugins/mantis/model/MantisViewState.java
@@ -19,4 +19,16 @@ private MantisViewState(final int code) {
public int getCode() {
return code;
}
+
+ public static MantisViewState invertViewState(MantisViewState viewState)
+ {
+ if(viewState.getCode() == 10)
+ {
+ return MantisViewState.PRIVATE;
+ }
+ else
+ {
+ return MantisViewState.PUBLIC;
+ }
+ }
}
diff --git a/src/main/java/hudson/plugins/mantis/soap/AbstractMantisSession.java b/src/main/java/hudson/plugins/mantis/soap/AbstractMantisSession.java
index baba76e..fd37a62 100644
--- a/src/main/java/hudson/plugins/mantis/soap/AbstractMantisSession.java
+++ b/src/main/java/hudson/plugins/mantis/soap/AbstractMantisSession.java
@@ -22,7 +22,9 @@ public abstract class AbstractMantisSession implements MantisSession {
protected MantisSite site;
- public abstract void addNote(int id, MantisNote note) throws MantisHandlingException;
+/* public abstract void addNote(int id, MantisNote note) throws MantisHandlingException; */
+
+ public abstract void addNote(int id, MantisNote note, final boolean ResolvedFilter) throws MantisHandlingException;
public abstract MantisIssue getIssue(int id) throws MantisHandlingException;
diff --git a/src/main/java/hudson/plugins/mantis/soap/MantisSession.java b/src/main/java/hudson/plugins/mantis/soap/MantisSession.java
index 60f419b..3b77a8b 100644
--- a/src/main/java/hudson/plugins/mantis/soap/MantisSession.java
+++ b/src/main/java/hudson/plugins/mantis/soap/MantisSession.java
@@ -13,7 +13,10 @@
*/
public interface MantisSession {
- void addNote(final int id, final MantisNote note) throws MantisHandlingException;
+
+
+ void addNote(final int id, final MantisNote note, final boolean ResolvedFilter) throws MantisHandlingException;
+
String getVersion() throws MantisHandlingException;
diff --git a/src/main/java/hudson/plugins/mantis/soap/mantis110/MantisSessionImpl.java b/src/main/java/hudson/plugins/mantis/soap/mantis110/MantisSessionImpl.java
index c1c2ffb..c736058 100644
--- a/src/main/java/hudson/plugins/mantis/soap/mantis110/MantisSessionImpl.java
+++ b/src/main/java/hudson/plugins/mantis/soap/mantis110/MantisSessionImpl.java
@@ -4,6 +4,7 @@
import hudson.plugins.mantis.MantisSite;
import hudson.plugins.mantis.model.MantisCategory;
import hudson.plugins.mantis.model.MantisIssue;
+import hudson.plugins.mantis.model.MantisIssueStatus;
import hudson.plugins.mantis.model.MantisNote;
import hudson.plugins.mantis.model.MantisProject;
import hudson.plugins.mantis.soap.AbstractMantisSession;
@@ -13,6 +14,7 @@
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
+import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.rpc.ServiceException;
import org.apache.axis.AxisProperties;
@@ -21,7 +23,7 @@
import org.apache.axis.client.Stub;
@Deprecated
-public final class MantisSessionImpl extends AbstractMantisSession {
+public class MantisSessionImpl extends AbstractMantisSession {
private final MantisConnectPortType portType;
@@ -65,21 +67,68 @@ public MantisIssue getIssue(final int id) throws MantisHandlingException {
throw new MantisHandlingException(e);
}
- return new MantisIssue(id, data.getSummary());
+ return new MantisIssue(id, data.getSummary(), data.getStatus().getName());
}
- public void addNote(final int id, final MantisNote note)
+ @Override
+ public void addNote(final int id, final MantisNote note,final boolean ResolvedFilter)
throws MantisHandlingException {
- final IssueNoteData data = new IssueNoteData();
- data.setText(note.getText());
- data.setView_state(new ObjectRef(BigInteger.valueOf(note.getViewState().getCode()), null));
+
+ boolean ResultFilter = true;
- try {
- portType.mc_issue_note_add(site.getUserName(), site.getPlainPassword(), BigInteger.valueOf(id), data);
- } catch (final RemoteException e) {
- throw new MantisHandlingException(e);
- }
+ if (ResolvedFilter == true)
+ {
+ ResultFilter = FilterStatus(id);
+ }
+
+ if(ResultFilter)
+ {
+
+ final hudson.plugins.mantis.soap.mantis110.IssueNoteData data = new hudson.plugins.mantis.soap.mantis110.IssueNoteData();
+
+
+ data.setText(note.getText());
+
+ data.setView_state(new hudson.plugins.mantis.soap.mantis110.ObjectRef(BigInteger.valueOf(note.getViewState().getCode()), null));
+
+ try
+ {
+ portType.mc_issue_note_add(site.getUserName(), site.getPlainPassword(), BigInteger.valueOf(id), data);
+ } catch (final RemoteException e) {
+ throw new MantisHandlingException(e);
+ }
+ }
+
+
}
+
+ public boolean FilterStatus(int id)
+ throws MantisHandlingException{
+
+ final MantisIssue IssueLFANote = getIssue(id);
+ String msgtest;
+ String st_Status = IssueLFANote.getStatus();
+ boolean ResultFilter;
+
+ //Filter on Status , in goal to add notes on Issues which aren't dead. Check Resolved Filter on Config
+ if (st_Status.equals(MantisIssueStatus.resolved.toString()))
+ {
+ // Print Log If Status is New ... Resolved... Closed
+ msgtest = "LOG : No Note : Status is " + st_Status +": != Resolved " ;
+ ResultFilter = false ;
+ }
+ LOGGER.log(Level.INFO, msgtest);
+ return ResultFilter;
+ }
+
+
+
public String getVersion() throws MantisHandlingException {
String version;
diff --git a/src/main/java/hudson/plugins/mantis/soap/mantis120/MantisSessionImpl.java b/src/main/java/hudson/plugins/mantis/soap/mantis120/MantisSessionImpl.java
index af7b17a..68d83af 100644
--- a/src/main/java/hudson/plugins/mantis/soap/mantis120/MantisSessionImpl.java
+++ b/src/main/java/hudson/plugins/mantis/soap/mantis120/MantisSessionImpl.java
@@ -19,6 +19,10 @@
import org.apache.axis.EngineConfiguration;
import org.apache.axis.client.AxisClient;
import org.apache.axis.client.Stub;
+import hudson.plugins.mantis.Utility;
+import hudson.plugins.mantis.model.MantisIssueStatus;
+import hudson.plugins.mantis.model.MantisViewState;
+import java.util.logging.Level;
public final class MantisSessionImpl extends AbstractMantisSession {
@@ -26,6 +30,7 @@ public final class MantisSessionImpl extends AbstractMantisSession {
public MantisSessionImpl(final MantisSite site) throws MantisHandlingException {
LOGGER.info("Mantis version is 1.2.X");
+
this.site = site;
try {
final URL endpoint = new URL(site.getUrl(), END_POINT);
@@ -60,24 +65,93 @@ public MantisIssue getIssue(final int id) throws MantisHandlingException {
try {
data =
portType.mc_issue_get(site.getUserName(), site.getPlainPassword(), BigInteger.valueOf(id));
+ System.out.println(data.getStatus().getName());
+
} catch (final RemoteException e) {
throw new MantisHandlingException(e);
}
-
- return new MantisIssue(id, data.getSummary());
+
+
+ //Lucas Fabre log issue name
+ String msg = "LOG : Issue Status : " + data.getStatus().getName();
+ LOGGER.log(Level.INFO,msg);
+ //-------------------------------------------------
+
+
+ return new MantisIssue(id, data.getSummary(), data.getStatus().getName());
}
- public void addNote(final int id, final MantisNote note)
+ /* @Override
+ public void addNote(final int id, final MantisNote note)
throws MantisHandlingException {
final IssueNoteData data = new IssueNoteData();
+
data.setText(note.getText());
data.setView_state(new ObjectRef(BigInteger.valueOf(note.getViewState().getCode()), null));
-
+
try {
portType.mc_issue_note_add(site.getUserName(), site.getPlainPassword(), BigInteger.valueOf(id), data);
} catch (final RemoteException e) {
throw new MantisHandlingException(e);
}
+ }*/
+
+
+ @Override
+ public void addNote(final int id, final MantisNote note,final boolean ResolvedFilter)
+ throws MantisHandlingException {
+
+ boolean ResultFilter = true;
+
+ if (ResolvedFilter == true)
+ {
+ ResultFilter = FilterStatus(id);
+ }
+
+ if(ResultFilter)
+ {
+
+ final IssueNoteData data = new IssueNoteData();
+
+
+ data.setText(note.getText());
+
+ data.setView_state(new ObjectRef(BigInteger.valueOf(note.getViewState().getCode()), null));
+
+ try
+ {
+ portType.mc_issue_note_add(site.getUserName(), site.getPlainPassword(), BigInteger.valueOf(id), data);
+ } catch (final RemoteException e) {
+ throw new MantisHandlingException(e);
+ }
+ }
+
+
+ }
+
+ public boolean FilterStatus(int id)
+ throws MantisHandlingException{
+
+ final MantisIssue IssueLFANote = getIssue(id);
+ String msgtest;
+ String st_Status = IssueLFANote.getStatus();
+ boolean ResultFilter;
+
+ //Filter on Status , in goal to add notes on Issues which aren't dead. Check Resolved Filter on Config
+ if (st_Status.equals(MantisIssueStatus.resolved.toString()))
+ {
+ // Print Log If Status is New ... Resolved... Closed
+ msgtest = "LOG : No Note : Status is " + st_Status +": != Resolved " ;
+ ResultFilter = false ;
+ }
+ LOGGER.log(Level.INFO, msgtest);
+ return ResultFilter;
}
public String getVersion() throws MantisHandlingException {
@@ -150,9 +224,11 @@ public int addIssue(MantisIssue issue) throws MantisHandlingException {
data.setCategory(category.getName());
data.setSummary(issue.getSummary());
data.setDescription(issue.getDescription());
+
ObjectRef viewStateRef = new ObjectRef(BigInteger.valueOf(issue.getViewState().getCode()), null);
data.setView_state(viewStateRef);
+
BigInteger addedIssueNo = null;
try {
addedIssueNo = portType.mc_issue_add(site.getUserName(), site.getPlainPassword(), data);
diff --git a/src/main/resources/hudson/plugins/mantis/MantisIssueRegister/config.jelly b/src/main/resources/hudson/plugins/mantis/MantisIssueRegister/config.jelly
index 7a74531..7ae1e0b 100644
--- a/src/main/resources/hudson/plugins/mantis/MantisIssueRegister/config.jelly
+++ b/src/main/resources/hudson/plugins/mantis/MantisIssueRegister/config.jelly
@@ -12,7 +12,7 @@
${%failure or unstable}
-
+
diff --git a/src/main/resources/hudson/plugins/mantis/MantisIssueRegister/config_ja.properties b/src/main/resources/hudson/plugins/mantis/MantisIssueRegister/config_ja.properties
index 397520a..a1f8801 100644
--- a/src/main/resources/hudson/plugins/mantis/MantisIssueRegister/config_ja.properties
+++ b/src/main/resources/hudson/plugins/mantis/MantisIssueRegister/config_ja.properties
@@ -1,4 +1,4 @@
Build\ status=\u30d3\u30eb\u30c9\u306e\u72b6\u614b
-failure=\u5931\u6557
+failureFAIL=\u5931\u6557
failure\ or\ unstable=\u5931\u6557\u304b\u4e0d\u5b89\u5b9a
Keep\ ticket\ private=\u30c1\u30b1\u30c3\u30c8\u3092\u975e\u516c\u958b\u306b\u3059\u308b
\ No newline at end of file
diff --git a/src/main/resources/hudson/plugins/mantis/MantisIssueUpdater/config.jelly b/src/main/resources/hudson/plugins/mantis/MantisIssueUpdater/config.jelly
index cf38f1e..33c921d 100644
--- a/src/main/resources/hudson/plugins/mantis/MantisIssueUpdater/config.jelly
+++ b/src/main/resources/hudson/plugins/mantis/MantisIssueUpdater/config.jelly
@@ -1,15 +1,49 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
diff --git a/src/test/java/hudson/plugins/mantis/MantisProjectPropertyConfigSubmitTest.java b/src/test/java/hudson/plugins/mantis/MantisProjectPropertyConfigSubmitTest.java
index 77398ba..0824019 100644
--- a/src/test/java/hudson/plugins/mantis/MantisProjectPropertyConfigSubmitTest.java
+++ b/src/test/java/hudson/plugins/mantis/MantisProjectPropertyConfigSubmitTest.java
@@ -1,39 +1,45 @@
package hudson.plugins.mantis;
+import com.gargoylesoftware.htmlunit.html.HtmlButton;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
-import hudson.model.Hudson;
import hudson.model.JobProperty;
import java.net.URL;
-import org.jvnet.hudson.test.HudsonTestCase;
+import jenkins.model.Jenkins;
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertNotNull;
+import static org.codehaus.groovy.runtime.DefaultGroovyMethods.last;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.jvnet.hudson.test.JenkinsRule;
+import org.jvnet.hudson.test.JenkinsRule.WebClient;
/**
*
* @author Seiji Sogabe
*/
-public class MantisProjectPropertyConfigSubmitTest extends HudsonTestCase {
+public class MantisProjectPropertyConfigSubmitTest {
+
+ @Rule
+ public JenkinsRule j = new JenkinsRule();
private WebClient webClient;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- webClient = new WebClient();
+ @Before
+ public void setUp() throws Exception {
+ webClient = j.createWebClient();
webClient.setCssEnabled(false);
webClient.setThrowExceptionOnFailingStatusCode(false);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
+ @Test
public void testConfigSubmit_001() throws Exception {
MantisProjectProperty.DescriptorImpl descriptor = new MantisProjectProperty.DescriptorImpl();
MantisSite s = new MantisSite(new URL("http://localhost/mantis/"), "V110", "test", "test", "test", "test");
descriptor.addSite(s);
- Hudson.getInstance().getDescriptorList(JobProperty.class).add(descriptor);
+ Jenkins.getInstance().getDescriptorList(JobProperty.class).add(descriptor);
HtmlForm form = webClient.goTo("configure").getFormByName("config");
@@ -46,13 +52,14 @@ public void testConfigSubmit_001() throws Exception {
}
+ @Test
public void testConfigSubmit_002() throws Exception {
MantisProjectProperty.DescriptorImpl descriptor = new MantisProjectProperty.DescriptorImpl();
MantisSite s = new MantisSite(new URL("http://localhost/mantis/"), "V110", "test", "test", null, null);
descriptor.addSite(s);
- Hudson.getInstance().getDescriptorList(JobProperty.class).add(descriptor);
+ Jenkins.getInstance().getDescriptorList(JobProperty.class).add(descriptor);
HtmlForm form = webClient.goTo("configure").getFormByName("config");
@@ -63,7 +70,7 @@ public void testConfigSubmit_002() throws Exception {
form.getInputByName("m.basicUserName").setValueAttribute("mantis");
form.getInputByName("m.basicPassword").setValueAttribute("mantis");
- submit(form);
+ form.submit((HtmlButton)last(form.getHtmlElementsByTagName("button")));
MantisSite[] sites = descriptor.getSites();
assertNotNull(sites);
diff --git a/src/test/java/hudson/plugins/mantis/MantisSiteTest.java b/src/test/java/hudson/plugins/mantis/MantisSiteTest.java
index 58b21ab..2bc1bfe 100644
--- a/src/test/java/hudson/plugins/mantis/MantisSiteTest.java
+++ b/src/test/java/hudson/plugins/mantis/MantisSiteTest.java
@@ -2,22 +2,33 @@
import hudson.plugins.mantis.model.MantisCategory;
import hudson.plugins.mantis.model.MantisIssue;
+import hudson.plugins.mantis.model.MantisIssueStatus;
import hudson.plugins.mantis.model.MantisProject;
import hudson.plugins.mantis.model.MantisViewState;
import java.net.URL;
-import org.junit.After;
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertFalse;
+import static junit.framework.TestCase.assertNotNull;
+import static junit.framework.TestCase.assertTrue;
+import static junit.framework.TestCase.fail;
import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
import org.junit.Test;
-import org.jvnet.hudson.test.HudsonTestCase;
+import org.jvnet.hudson.test.JenkinsRule;
/**
* Test class.
*
* @author Seiji Sogabe
*/
-public class MantisSiteTest extends HudsonTestCase {
+@Ignore(value = "not work behind a proxy")
+public class MantisSiteTest {
- private static String MANTIS_URL = "http://bacons.ddo.jp/mantis/";
+ @Rule
+ public JenkinsRule j = new JenkinsRule();
+
+ private static final String MANTIS_URL = "http://bacons.ddo.jp/mantis/";
private URL mantisUrl;
@@ -29,19 +40,11 @@ public MantisSiteTest() {
}
@Before
- @Override
public void setUp() throws Exception {
- super.setUp();
mantisUrl = new URL(MANTIS_URL);
googleUrl = new URL("http://www.google.com");
}
- @After
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
@Test
public void testIsConnect() {
target = createMantisSite();
@@ -83,7 +86,7 @@ public void testGetIssue_NotFound() {
@Test
public void updateIssue() throws MantisHandlingException {
target = createMantisSite();
- target.updateIssue(232, "Updated by Jenkins Mantis Plugin.", false);
+ target.updateIssue(232, "Updated by Jenkins Mantis Plugin.","", false, false, false, false, false);
}
@Test
@@ -93,7 +96,9 @@ public void addIssue() throws MantisHandlingException {
String description = "Added by Jenkins Mantis Plugin.";
MantisProject project = new MantisProject(2, "Jenkins Project");
MantisCategory category = new MantisCategory("plugin");
- MantisIssue issue = new MantisIssue(project, category, summary, description, MantisViewState.PUBLIC);
+
+
+ MantisIssue issue = new MantisIssue(project, category, summary, description,MantisViewState.PUBLIC,"acknowledged");
target.addIssue(issue);
}
@@ -103,10 +108,13 @@ public void addIssue_private() throws MantisHandlingException {
String summary = "Build failed(Private)";
String description = "Added by Jenkins Mantis Plugin.";
MantisProject project = new MantisProject(2, "Jenkins Project");
- MantisCategory category = new MantisCategory("plugin");
- MantisIssue issue = new MantisIssue(project, category, summary, description, MantisViewState.PRIVATE);
+ MantisCategory category;
+ category = new MantisCategory("plugin");
+
+ MantisIssue issue = new MantisIssue(project, category, summary, description,MantisViewState.PRIVATE,"closed");
target.addIssue(issue);
- }
+ }
+
private MantisSite createMantisSite() {
return new MantisSite(mantisUrl, "V120", "jenkinsci", "jenkinsci", null, null);
}