Authentication support for access a private Jira instalation. MPJIRA-8
Enable retrieving component-specific issues. MPJIRA-11 MPJIRA-13 git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@232355 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ef704f9ac6
commit
2134c137ab
@ -54,8 +54,18 @@
|
|||||||
project="${pom}"
|
project="${pom}"
|
||||||
output="${maven.build.dir}/jira/jira-results.xml"
|
output="${maven.build.dir}/jira/jira-results.xml"
|
||||||
nbEntries="${maven.jira.nbentries}"
|
nbEntries="${maven.jira.nbentries}"
|
||||||
|
statusIds="${maven.jira.status}"
|
||||||
|
filter="${maven.jira.filter}"
|
||||||
|
resolutionIds="${maven.jira.resolution}"
|
||||||
|
priorityIds="${maven.jira.priority}"
|
||||||
|
webUser="${maven.jira.webUser}"
|
||||||
|
webPassword="${maven.jira.webPassword}"
|
||||||
|
jiraUser="${maven.jira.jiraUser}"
|
||||||
|
jiraPassword="${maven.jira.jiraPassword}"
|
||||||
|
component="${maven.jira.component}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<mkdir dir="${maven.gen.docs}"/>
|
||||||
<doc:jslFile
|
<doc:jslFile
|
||||||
input="${maven.build.dir}/jira/jira-results.xml"
|
input="${maven.build.dir}/jira/jira-results.xml"
|
||||||
output="${maven.gen.docs}/jira.xml"
|
output="${maven.gen.docs}/jira.xml"
|
||||||
|
|||||||
@ -17,4 +17,13 @@
|
|||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# P L U G I N P R O P E R I E S
|
# P L U G I N P R O P E R I E S
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
|
maven.jira.webUser=
|
||||||
|
maven.jira.webPassword=
|
||||||
|
maven.jira.jiraUser=
|
||||||
|
maven.jira.jiraPassword=
|
||||||
maven.jira.nbentries=1000
|
maven.jira.nbentries=1000
|
||||||
|
maven.jira.filter=
|
||||||
|
maven.jira.status=Open,In Progress,Reopened
|
||||||
|
maven.jira.resolution=Unresolved
|
||||||
|
maven.jira.priority=
|
||||||
|
maven.jira.component=
|
||||||
|
|||||||
@ -17,184 +17,471 @@ package org.apache.maven.jira;
|
|||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.httpclient.Credentials;
|
||||||
import org.apache.commons.httpclient.Header;
|
import org.apache.commons.httpclient.Header;
|
||||||
import org.apache.commons.httpclient.HostConfiguration;
|
import org.apache.commons.httpclient.HostConfiguration;
|
||||||
import org.apache.commons.httpclient.HttpClient;
|
import org.apache.commons.httpclient.HttpClient;
|
||||||
|
import org.apache.commons.httpclient.HttpException;
|
||||||
import org.apache.commons.httpclient.HttpState;
|
import org.apache.commons.httpclient.HttpState;
|
||||||
import org.apache.commons.httpclient.HttpStatus;
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.httpclient.StatusLine;
|
import org.apache.commons.httpclient.StatusLine;
|
||||||
import org.apache.commons.httpclient.UsernamePasswordCredentials;
|
import org.apache.commons.httpclient.UsernamePasswordCredentials;
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.apache.maven.jelly.MavenJellyContext;
|
import org.apache.maven.jelly.MavenJellyContext;
|
||||||
import org.apache.maven.project.Project;
|
import org.apache.maven.project.Project;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
public class JiraDownloader
|
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Log for debug output
|
* Gets relevant issues in RSS from a given JIRA installation.
|
||||||
|
*
|
||||||
|
* Based on version 1.1.2 and patch by Dr. Spock (MPJIRA-8)
|
||||||
|
*
|
||||||
|
* @author mfranken@xebia.com
|
||||||
*/
|
*/
|
||||||
private static Log LOG = LogFactory.getLog(JiraDownloader.class);
|
public final class JiraDownloader {
|
||||||
|
/**
|
||||||
|
* Log for debug output.
|
||||||
|
*/
|
||||||
|
private static Log log = LogFactory.getLog(JiraDownloader.class);
|
||||||
|
|
||||||
/** Output file for xml document */
|
/** Output file for xml document. */
|
||||||
private File output;
|
private File output;
|
||||||
|
|
||||||
/** Number of entries max */
|
/** The maximum number of entries to show. */
|
||||||
private int nbEntriesMax;
|
private int nbEntriesMax;
|
||||||
|
|
||||||
|
/** The filter to apply to query to JIRA. */
|
||||||
|
private String filter;
|
||||||
|
|
||||||
|
/** Ids of status to show, as comma separated string. */
|
||||||
|
private String statusIds;
|
||||||
|
|
||||||
|
/** Ids of resolution to show, as comma separated string. */
|
||||||
|
private String resolutionIds;
|
||||||
|
|
||||||
|
/** Ids of priority to show, as comma separated string. */
|
||||||
|
private String priorityIds;
|
||||||
|
|
||||||
|
/** The component to show. */
|
||||||
|
private String component;
|
||||||
|
|
||||||
|
/** The username to log into JIRA. */
|
||||||
|
private String jiraUser;
|
||||||
|
|
||||||
|
/** The password to log into JIRA. */
|
||||||
|
private String jiraPassword;
|
||||||
|
|
||||||
|
/** The username to log into webserver. */
|
||||||
|
private String webUser;
|
||||||
|
|
||||||
|
/** The password to log into webserver. */
|
||||||
|
private String webPassword;
|
||||||
|
|
||||||
|
/** The maven project. */
|
||||||
private Project project;
|
private Project project;
|
||||||
|
|
||||||
/**
|
/** Mapping containing all JIRA status values. */
|
||||||
* Set the output file for the log.
|
private static Map statusMap = new HashMap();
|
||||||
* @param output the output file
|
|
||||||
*/
|
/** Mapping containing all JIRA resolution values. */
|
||||||
public void setOutput(File output)
|
private static Map resolutionMap = new HashMap();
|
||||||
{
|
|
||||||
this.output = output;
|
/** Mapping containing all JIRA priority values. */
|
||||||
|
private static Map priorityMap = new HashMap();
|
||||||
|
|
||||||
|
static {
|
||||||
|
statusMap.put("Open", "1");
|
||||||
|
statusMap.put("In Progress", "3");
|
||||||
|
statusMap.put("Reopened", "4");
|
||||||
|
statusMap.put("Resolved", "5");
|
||||||
|
statusMap.put("Closed", "6");
|
||||||
|
|
||||||
|
resolutionMap.put("Unresolved", "-1");
|
||||||
|
resolutionMap.put("Fixed", "1");
|
||||||
|
resolutionMap.put("Won't Fix", "2");
|
||||||
|
resolutionMap.put("Duplicate", "3");
|
||||||
|
resolutionMap.put("Incomplete", "4");
|
||||||
|
resolutionMap.put("Cannot Reproduce", "5");
|
||||||
|
|
||||||
|
priorityMap.put("Blocker", "1");
|
||||||
|
priorityMap.put("Critical", "2");
|
||||||
|
priorityMap.put("Major", "3");
|
||||||
|
priorityMap.put("Minor", "4");
|
||||||
|
priorityMap.put("Trivial", "5");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Project
|
* Creates a filter given the maven.jira parameters and some defaults.
|
||||||
|
*
|
||||||
|
* @return request parameters to be added to URL used for downloading the JIRA issues
|
||||||
*/
|
*/
|
||||||
public Object getProject()
|
private String createFilter() {
|
||||||
{
|
if (this.filter != null && this.filter.length() > 0) {
|
||||||
return project;
|
if (this.filter.charAt(0) == '&') {
|
||||||
|
return this.filter.substring(1);
|
||||||
|
}
|
||||||
|
return this.filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuffer localFilter = new StringBuffer();
|
||||||
|
// get the Status Ids
|
||||||
|
if (statusIds != null) {
|
||||||
|
String[] stats = statusIds.split(",");
|
||||||
|
for (int i = 0; i < stats.length; i++) {
|
||||||
|
String statusParam = (String) statusMap.get(stats[i]);
|
||||||
|
if (statusParam != null) {
|
||||||
|
localFilter.append("&statusIds=" + statusParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// get the Priority Ids
|
||||||
|
if (priorityIds != null) {
|
||||||
|
String[] prios = priorityIds.split(",");
|
||||||
|
for (int i = 0; i < prios.length; i++) {
|
||||||
|
String priorityParam = (String) priorityMap.get(prios[i]);
|
||||||
|
if (priorityParam != null) {
|
||||||
|
localFilter.append("&priorityIds=" + priorityParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resolutionIds != null) {
|
||||||
|
// get the Resolution Ids
|
||||||
|
String[] resos = resolutionIds.split(",");
|
||||||
|
for (int i = 0; i < resos.length; i++) {
|
||||||
|
String resoParam = (String) resolutionMap.get(resos[i]);
|
||||||
|
if (resoParam != null) {
|
||||||
|
localFilter.append("&resolutionIds=" + resoParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// add all components
|
||||||
|
if (component != null) {
|
||||||
|
String[] components = component.split(",");
|
||||||
|
for (int i = 0; i < components.length; i++) {
|
||||||
|
if (components[i].length() > 0) {
|
||||||
|
localFilter.append("&component=" + components[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add default sorting (by priority and then creation date)
|
||||||
|
String sort = "&sorter/field=created&sorter/order=DESC" + "&sorter/field=priority&sorter/order=DESC";
|
||||||
|
return localFilter + sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the query on the JIRA server.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
* on error
|
||||||
|
*/
|
||||||
|
public void doExecute() throws Exception {
|
||||||
|
if (project == null) {
|
||||||
|
throw new Exception("No project set.");
|
||||||
|
} else {
|
||||||
|
if (project.getIssueTrackingUrl() == null) {
|
||||||
|
throw new Exception("No issue tracking url set.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpClient cl = new HttpClient();
|
||||||
|
HttpState state = new HttpState();
|
||||||
|
HostConfiguration hc = new HostConfiguration();
|
||||||
|
cl.setHostConfiguration(hc);
|
||||||
|
cl.setState(state);
|
||||||
|
|
||||||
|
determineProxy(cl);
|
||||||
|
// get the Jira URL and project id
|
||||||
|
String url = project.getIssueTrackingUrl();
|
||||||
|
// chop off the parameter part
|
||||||
|
int pos = url.indexOf("?");
|
||||||
|
// and get the id while we're at it
|
||||||
|
String id = "";
|
||||||
|
if (pos >= 0) {
|
||||||
|
// url
|
||||||
|
id = url.substring(url.lastIndexOf("=") + 1);
|
||||||
|
}
|
||||||
|
// TODO: fail the build in the else block, issueTrackingUrl has to include id
|
||||||
|
|
||||||
|
String jiraUrl = url.substring(0, url.lastIndexOf("/"));
|
||||||
|
if (jiraUrl.endsWith("secure")) {
|
||||||
|
jiraUrl = jiraUrl.substring(0, jiraUrl.lastIndexOf("/"));
|
||||||
|
}
|
||||||
|
log.info("Jira lives at: " + jiraUrl);
|
||||||
|
doAuthentication(cl, jiraUrl);
|
||||||
|
|
||||||
|
// create the URL for getting the proper iussues from JIRA
|
||||||
|
String fullURL = jiraUrl + "/secure/IssueNavigator.jspa?view=rss&pid=" + id;
|
||||||
|
fullURL += createFilter();
|
||||||
|
fullURL += "&tempMax=" + nbEntriesMax + "&reset=true&decorator=none";
|
||||||
|
|
||||||
|
// execute the GET
|
||||||
|
download(cl, fullURL);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error accessing " + project.getIssueTrackingUrl(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authenticate against webserver and into JIRA if we have to.
|
||||||
|
*
|
||||||
|
* @param client
|
||||||
|
* the HttpClient
|
||||||
|
* @param jiraUrl
|
||||||
|
* the JIRA installation
|
||||||
|
*/
|
||||||
|
private void doAuthentication(HttpClient client, final String jiraUrl) {
|
||||||
|
// check and prepare for basic authentication
|
||||||
|
if (webUser != null && webUser.length() > 0) {
|
||||||
|
client.getState().setAuthenticationPreemptive(true);
|
||||||
|
Credentials defaultcreds = new UsernamePasswordCredentials(webUser, webPassword);
|
||||||
|
log.info("Using username: " + webUser + " for Basic Authentication against the webserver at " + jiraUrl);
|
||||||
|
client.getState().setCredentials(null, null, defaultcreds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// log into JIRA if we have to
|
||||||
|
String loginUrl = null;
|
||||||
|
if (jiraUser != null && jiraUser.length() > 0 && jiraPassword != null) {
|
||||||
|
StringBuffer loginLink = new StringBuffer(jiraUrl);
|
||||||
|
loginLink.append("/login.jsp?os_destination=/secure/");
|
||||||
|
loginLink.append("&os_username=").append(jiraUser);
|
||||||
|
log.info("Login URL: " + loginLink + "&os_password=*******");
|
||||||
|
loginLink.append("&os_password=").append(jiraPassword);
|
||||||
|
loginUrl = loginLink.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// execute the login
|
||||||
|
if (loginUrl != null) {
|
||||||
|
GetMethod loginGet = new GetMethod(loginUrl);
|
||||||
|
try {
|
||||||
|
client.executeMethod(loginGet);
|
||||||
|
log.info("Succesfully logged in into JIRA.");
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.error("Error trying to login into JIRA:", e);
|
||||||
|
} else {
|
||||||
|
log.error("Error trying to login into JIRA. Cause is: " + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
// continue any way, probably will fail later if authentication was necesaaray afterall
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup proxy access if we have to.
|
||||||
|
*
|
||||||
|
* @param client
|
||||||
|
* the HttpClient
|
||||||
|
*/
|
||||||
|
private void determineProxy(HttpClient client) {
|
||||||
|
// see whether there is any proxy defined in maven
|
||||||
|
if (project == null) {
|
||||||
|
log.error("No project set. No proxy info available.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MavenJellyContext ctx = project.getContext();
|
||||||
|
if (ctx == null) {
|
||||||
|
log.error("Maven project has no context. No proxy info available.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String proxyHost = ctx.getProxyHost();
|
||||||
|
|
||||||
|
if (proxyHost != null) {
|
||||||
|
String proxyPort = ctx.getProxyPort();
|
||||||
|
client.getHostConfiguration().setProxy(proxyHost, Integer.parseInt(proxyPort));
|
||||||
|
log.info("Using proxy: " + proxyHost + " at port " + proxyPort);
|
||||||
|
String proxyUser = ctx.getProxyUserName();
|
||||||
|
if (proxyUser != null) {
|
||||||
|
log.info("Using proxy user: " + proxyUser);
|
||||||
|
String proxyPass = ctx.getProxyPassword();
|
||||||
|
client.getState().setProxyCredentials(null, null, new UsernamePasswordCredentials(proxyUser, proxyPass));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Downloads the given link using the configured HttpClient, possibly following redirects.
|
||||||
|
*
|
||||||
|
* @param cl
|
||||||
|
* the HttpClient
|
||||||
|
* @param link
|
||||||
|
* the JiraUrl
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private void download(final HttpClient cl, final String link) {
|
||||||
|
try {
|
||||||
|
GetMethod gm = new GetMethod(link);
|
||||||
|
log.info("Downloading " + link);
|
||||||
|
gm.setFollowRedirects(true);
|
||||||
|
cl.executeMethod(gm);
|
||||||
|
final String strGetResponseBody = gm.getResponseBodyAsString();
|
||||||
|
// write the reponse to file
|
||||||
|
PrintWriter pw = new PrintWriter(new FileWriter(output));
|
||||||
|
pw.print(strGetResponseBody);
|
||||||
|
pw.close();
|
||||||
|
StatusLine sl = gm.getStatusLine();
|
||||||
|
if (sl == null) {
|
||||||
|
log.info("Unknown error validating link : " + link);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we get a redirect, do so
|
||||||
|
if (gm.getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) {
|
||||||
|
Header locationHeader = gm.getResponseHeader("Location");
|
||||||
|
if (locationHeader == null) {
|
||||||
|
log.info("Site sent redirect, but did not set Location header");
|
||||||
|
} else {
|
||||||
|
String newLink = locationHeader.getValue();
|
||||||
|
log.debug("Following redirect to " + newLink);
|
||||||
|
download(cl, newLink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gm.getStatusCode() != HttpStatus.SC_OK) {
|
||||||
|
log.warn("Received: [" + gm.getStatusCode() + "]");
|
||||||
|
}
|
||||||
|
} catch (HttpException e) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.error("Error downloading issues from JIRA:", e);
|
||||||
|
} else {
|
||||||
|
log.error("Error downloading issues from JIRA. Cause is: " + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.error("Error downloading issues from JIRA:", e);
|
||||||
|
} else {
|
||||||
|
log.error("Error downloading issues from JIRA. Cause is: " + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the output file for the log.
|
||||||
|
*
|
||||||
|
* @param thisOutput
|
||||||
|
* the output file
|
||||||
|
*/
|
||||||
|
public void setOutput(final File thisOutput) {
|
||||||
|
this.output = thisOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the project.
|
* Sets the project.
|
||||||
* @param project The project to set
|
*
|
||||||
|
* @param thisProject
|
||||||
|
* The project to set
|
||||||
*/
|
*/
|
||||||
public void setProject(Object project)
|
public void setProject(final Object thisProject) {
|
||||||
{
|
this.project = (Project) thisProject;
|
||||||
//System.out.println("Setting project: " + project);
|
|
||||||
this.project = (Project) project;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the number of entries.
|
* Sets the maximum number of Issues to show.
|
||||||
* @param nbEntries The number of entries
|
*
|
||||||
|
* @param nbEntries
|
||||||
|
* The maximum number of Issues
|
||||||
*/
|
*/
|
||||||
public void setNbEntries(int nbEntries)
|
public void setNbEntries(final int nbEntries) {
|
||||||
{
|
|
||||||
nbEntriesMax = nbEntries;
|
nbEntriesMax = nbEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doExecute() throws Exception
|
/**
|
||||||
{
|
* Sets the statusIds.
|
||||||
MavenJellyContext ctx;
|
*
|
||||||
String proxyHost;
|
* @param thisStatusIds
|
||||||
String proxyPort;
|
* The id(s) of the status to show, as comma separated string
|
||||||
String proxyUser;
|
*/
|
||||||
String proxyPass;
|
public void setStatusIds(final String thisStatusIds) {
|
||||||
String link;
|
statusIds = thisStatusIds;
|
||||||
|
|
||||||
if (getProject() == null)
|
|
||||||
{
|
|
||||||
throw new Exception("No project set.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (((Project) getProject()).getIssueTrackingUrl() == null)
|
|
||||||
{
|
|
||||||
throw new Exception("No issue tracking url set.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
String url = ((Project) getProject()).getIssueTrackingUrl();
|
|
||||||
int pos = url.indexOf("?");
|
|
||||||
String id = url.substring(pos+4);
|
|
||||||
url = url.substring(0, url.lastIndexOf("/"));
|
|
||||||
link = url + "/secure/IssueNavigator.jspa?view=rss&pid=" + id + "&sorter/field=issuekey&sorter/order=DESC&sorter/field=status&sorter/order=DESC&tempMax=" + String.valueOf(nbEntriesMax) + "&reset=true&decorator=none";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = ((Project) getProject()).getContext();
|
/**
|
||||||
|
* Sets the priorityIds.
|
||||||
proxyHost = ctx.getProxyHost();
|
*
|
||||||
proxyPort = ctx.getProxyPort();
|
* @param thisPriorityIds
|
||||||
proxyUser = ctx.getProxyUserName();
|
* The id(s) of the priority to show, as comma separated string
|
||||||
proxyPass = ctx.getProxyPassword();
|
*/
|
||||||
|
public void setPriorityIds(final String thisPriorityIds) {
|
||||||
try
|
priorityIds = thisPriorityIds;
|
||||||
{
|
|
||||||
HttpClient cl = new HttpClient();
|
|
||||||
HostConfiguration hc = new HostConfiguration();
|
|
||||||
|
|
||||||
if (proxyHost != null)
|
|
||||||
{
|
|
||||||
hc.setProxy(proxyHost, Integer.parseInt(proxyPort));
|
|
||||||
}
|
|
||||||
HttpState state = new HttpState();
|
|
||||||
|
|
||||||
if (proxyUser != null && proxyPass != null)
|
|
||||||
{
|
|
||||||
state.setProxyCredentials(null, null, new UsernamePasswordCredentials(proxyUser, proxyPass));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cl.setHostConfiguration(hc);
|
/**
|
||||||
cl.setState(state);
|
* Sets the resolutionIds.
|
||||||
|
*
|
||||||
// execute the GET
|
* @param thisResolutionIds
|
||||||
GetMethod gm = download(cl, link);
|
* The id(s) of the resolution to show, as comma separated string
|
||||||
StatusLine sl = gm.getStatusLine();
|
*/
|
||||||
|
public void setResolutionIds(final String thisResolutionIds) {
|
||||||
if (sl == null) {
|
resolutionIds = thisResolutionIds;
|
||||||
LOG.info("Unknown error validating link : " + link);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gm.getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY)
|
/**
|
||||||
{
|
* Sets the password for authentication against the webserver.
|
||||||
Header locationHeader = gm.getResponseHeader("Location");
|
*
|
||||||
if (locationHeader == null) {
|
* @param thisWebPassword
|
||||||
LOG.info("Site sent redirect, but did not set Location header");
|
* The password of the webserver
|
||||||
} else {
|
*/
|
||||||
String newLink = locationHeader.getValue();
|
public void setWebPassword(final String thisWebPassword) {
|
||||||
LOG.debug("Following 1 redirect to " + newLink);
|
this.webPassword = thisWebPassword;
|
||||||
gm = download(cl, newLink);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gm.getStatusCode() != HttpStatus.SC_OK)
|
/**
|
||||||
{
|
* Sets the username for authentication against the webserver.
|
||||||
String msg = "Received: [" + gm.getStatusCode() + "] for " + link;
|
*
|
||||||
LOG.info(msg);
|
* @param thisWebUser
|
||||||
System.out.println(msg);
|
* The username of the webserver
|
||||||
|
*/
|
||||||
|
public void setWebUser(final String thisWebUser) {
|
||||||
|
this.webUser = thisWebUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the password to log into a secured JIRA.
|
||||||
|
*
|
||||||
|
* @param thisJiraPassword
|
||||||
|
* The password for JIRA
|
||||||
|
*/
|
||||||
|
public void setJiraPassword(final String thisJiraPassword) {
|
||||||
|
this.jiraPassword = thisJiraPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the username to log into a secured JIRA.
|
||||||
|
*
|
||||||
|
* @param thisJiraUser
|
||||||
|
* The username for JIRA
|
||||||
|
*/
|
||||||
|
public void setJiraUser(final String thisJiraUser) {
|
||||||
|
this.jiraUser = thisJiraUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the filter to apply to query to JIRA.
|
||||||
|
*
|
||||||
|
* @param thisFilter
|
||||||
|
* The filter to query JIRA
|
||||||
|
*/
|
||||||
|
public void setFilter(final String thisFilter) {
|
||||||
|
this.filter = thisFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the component(s) to apply to query JIRA.
|
||||||
|
*
|
||||||
|
* @param theseComponents
|
||||||
|
* The id(s) of components to show, as comma separated string
|
||||||
|
*/
|
||||||
|
public void setComponent(final String theseComponents) {
|
||||||
|
this.component = theseComponents;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOG.warn("Error accessing " + link);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private GetMethod download(HttpClient cl, String link)
|
|
||||||
{
|
|
||||||
GetMethod gm = new GetMethod(link);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
System.out.println("Downloading " + link);
|
|
||||||
gm.setFollowRedirects(true);
|
|
||||||
cl.executeMethod(gm);
|
|
||||||
final String strGetResponseBody = gm.getResponseBodyAsString();
|
|
||||||
PrintWriter pw = new PrintWriter(new FileWriter(output));
|
|
||||||
pw.print(strGetResponseBody);
|
|
||||||
pw.close();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
System.out.println("Error downloading " + link);
|
|
||||||
}
|
|
||||||
return gm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -42,22 +42,30 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th style="width:150px">Key</th>
|
<th style="width:150px">Key</th>
|
||||||
<th>Summary</th>
|
<th>Summary</th>
|
||||||
<th style="width:150px">Status</th>
|
<th style="width:150px">Created</th>
|
||||||
<th style="width:150px">Resolution</th>
|
<th style="width:50px">Priority</th>
|
||||||
<th style="width:150px">By</th>
|
<th style="width:50px">Status</th>
|
||||||
|
<th style="width:100px">Resolution</th>
|
||||||
|
<th style="width:100px">Assigned to</th>
|
||||||
|
<th style="width:100px">Reported by</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<x:forEach var="entry" select="item">
|
<x:forEach var="entry" select="item">
|
||||||
<j:set var="key"><x:expr select="$entry/key"/></j:set>
|
<j:set var="key"><x:expr select="$entry/key"/></j:set>
|
||||||
<j:set var="link"><x:expr select="$entry/link"/></j:set>
|
<j:set var="link"><x:expr select="$entry/link"/></j:set>
|
||||||
|
<j:set var="createdate"><x:expr select="$entry/created"/></j:set>
|
||||||
|
<j:set var="priority"><x:expr select="$entry/priority"/></j:set>
|
||||||
<j:set var="status"><x:expr select="$entry/status"/></j:set>
|
<j:set var="status"><x:expr select="$entry/status"/></j:set>
|
||||||
<j:set var="summary"><x:expr select="$entry/summary"/></j:set>
|
<j:set var="summary"><x:expr select="$entry/summary"/></j:set>
|
||||||
<j:set var="assignee"><x:expr select="$entry/assignee"/></j:set>
|
<j:set var="assignee"><x:expr select="$entry/assignee"/></j:set>
|
||||||
|
<j:set var="reporter"><x:expr select="$entry/reporter"/></j:set>
|
||||||
<j:set var="resolution"><x:expr select="$entry/resolution"/></j:set>
|
<j:set var="resolution"><x:expr select="$entry/resolution"/></j:set>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="${link}">${key}</a></td>
|
<td><a href="${link}">${key}</a></td>
|
||||||
<td>${summary}</td>
|
<td>${summary}</td>
|
||||||
|
<td>${createdate}</td>
|
||||||
|
<td>${priority}</td>
|
||||||
<td>
|
<td>
|
||||||
<j:choose>
|
<j:choose>
|
||||||
<j:when test="${status.equalsIgnoreCase('Closed')}">
|
<j:when test="${status.equalsIgnoreCase('Closed')}">
|
||||||
@ -82,6 +90,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>${resolution}</td>
|
<td>${resolution}</td>
|
||||||
<td>${assignee}</td>
|
<td>${assignee}</td>
|
||||||
|
<td>${reporter}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</x:forEach>
|
</x:forEach>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@ -24,6 +24,10 @@
|
|||||||
<author email="brett@apache.org">Brett Porter</author>
|
<author email="brett@apache.org">Brett Porter</author>
|
||||||
</properties>
|
</properties>
|
||||||
<body>
|
<body>
|
||||||
|
<release version="1.2-SNAPSHOT" date="in SVN">
|
||||||
|
<action dev="carlos" type="fix" issue="MPJIRA-11" due-to="Michael Franken">Enable retrieving component-specific issues.</action>
|
||||||
|
<action dev="carlos" type="fix" issue="MPJIRA-8" due-to="Michael Franken">Authentication support for access a private Jira instalation.</action>
|
||||||
|
</release>
|
||||||
<release version="1.1.2" date="2004-10-23">
|
<release version="1.1.2" date="2004-10-23">
|
||||||
<action dev="evenisse" type="fix" issue="MPJIRA-3">Fix jira downloading url for some jira instance like Apache.</action>
|
<action dev="evenisse" type="fix" issue="MPJIRA-3">Fix jira downloading url for some jira instance like Apache.</action>
|
||||||
</release>
|
</release>
|
||||||
|
|||||||
@ -35,12 +35,15 @@
|
|||||||
<source><issueTrackingUrl>http://jira.codehaus.org/secure/BrowseProject.jspa?id=10450</issueTrackingUrl></source>
|
<source><issueTrackingUrl>http://jira.codehaus.org/secure/BrowseProject.jspa?id=10450</issueTrackingUrl></source>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
2. make sure that your project allows group Anyone to view jira issues
|
2. Determine the credentials to log into the webserver, if any. The plugin supports basic authentication (and SSL).
|
||||||
(you may or may not need to also set your jira installation type to
|
Add the credentials to the project.properties, as maven.jira.webUser and maven.jira.webPassword
|
||||||
public - this is in General Configuration under administration).
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
3. log out of jira (if you are using Remember me feature) and test your setup
|
3. Determine the JIRA account to login to the JIRA installation.
|
||||||
|
Add the credentials to the project.properties, as maven.jira.jiraUser and maven.jira.jiraPassword
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
4. log out of jira (if you are using Remember me feature) and test your setup
|
||||||
by going to url like this one:
|
by going to url like this one:
|
||||||
</p>
|
</p>
|
||||||
<source>[JIRA URL]/secure/IssueNavigator.jspa?view=rss&pid=[JIRA PROJECT ID]&sorter/field=issuekey&sorter/order=DESC&sorter/field=status&sorter/order=DESC&tempMax=1000&reset=true</source>
|
<source>[JIRA URL]/secure/IssueNavigator.jspa?view=rss&pid=[JIRA PROJECT ID]&sorter/field=issuekey&sorter/order=DESC&sorter/field=status&sorter/order=DESC&tempMax=1000&reset=true</source>
|
||||||
@ -48,11 +51,25 @@
|
|||||||
<source>http://jira.codehaus.org/secure/IssueNavigator.jspa?view=rss&pid=10450&sorter/field=issuekey&sorter/order=DESC&sorter/field=status&sorter/order=DESC&tempMax=1000&reset=true</source>
|
<source>http://jira.codehaus.org/secure/IssueNavigator.jspa?view=rss&pid=10450&sorter/field=issuekey&sorter/order=DESC&sorter/field=status&sorter/order=DESC&tempMax=1000&reset=true</source>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
4. add this to your project.xml in reports section
|
5. add this to your project.xml in reports section
|
||||||
</p>
|
</p>
|
||||||
<source><report>maven-jira-plugin</report></source>
|
<source><report>maven-jira-plugin</report></source>
|
||||||
<p>
|
<p>
|
||||||
5. run site:generate and you should have jira.html in your ${basedir}/target/docs directory
|
6. run maven site (or just maven maven-jira-plugin:report xdoc) and you should have jira.html in your ${basedir}/target/docs directory
|
||||||
|
</p>
|
||||||
|
</answer>
|
||||||
|
</faq>
|
||||||
|
<faq id="untrusted cert">
|
||||||
|
<question>
|
||||||
|
My JIRA installation runs SSL with a self signed/home brewn certificate.
|
||||||
|
I get an error message that the certificate is untrusted. How do I proceed?
|
||||||
|
</question>
|
||||||
|
<answer>
|
||||||
|
<p>
|
||||||
|
Add the server certificate to your JAVA. You can get the certificate by exporting it from your browser.
|
||||||
|
With IE you click on the certificate info, go to the details TAB and export as .DER by clicking on 'Copy to File...'.
|
||||||
|
Using SUN's keytool you can import the certificate in your 'truststore'. It is located in $JAVA_HOME/jre/lib/security/cacerts
|
||||||
|
Import it using <source>keytool -import -file <servercert>.cer -keystore cacerts</source>
|
||||||
</p>
|
</p>
|
||||||
</answer>
|
</answer>
|
||||||
</faq>
|
</faq>
|
||||||
|
|||||||
@ -25,17 +25,17 @@
|
|||||||
<goals>
|
<goals>
|
||||||
<goal>
|
<goal>
|
||||||
<name>maven-jira-plugin:deregister</name>
|
<name>maven-jira-plugin:deregister</name>
|
||||||
<description>
|
<description>The standard goal name for report plugins to register themselves with the site plugin.
|
||||||
</description>
|
</description>
|
||||||
</goal>
|
</goal>
|
||||||
<goal>
|
<goal>
|
||||||
<name>maven-jira-plugin:register</name>
|
<name>maven-jira-plugin:register</name>
|
||||||
<description>
|
<description>The standard goal name for report plugins to deregister themselves from the site.
|
||||||
</description>
|
</description>
|
||||||
</goal>
|
</goal>
|
||||||
<goal>
|
<goal>
|
||||||
<name>maven-jira-plugin:report</name>
|
<name>maven-jira-plugin:report</name>
|
||||||
<description>Generate report with all entries defined in Jira.</description>
|
<description>Generate report for entries defined in Jira.</description>
|
||||||
</goal>
|
</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@ -28,16 +28,141 @@
|
|||||||
<th>Property</th>
|
<th>Property</th>
|
||||||
<th>Optional?</th>
|
<th>Optional?</th>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
|
<th>Default value</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>maven.jira.nbentries</td>
|
<td>maven.jira.nbentries</td>
|
||||||
<td>Yes</td>
|
<td>Yes</td>
|
||||||
<td>
|
<td>
|
||||||
<p>
|
<p>
|
||||||
Defines the number of entries we want to obtain into the report.
|
Defines the maximum number of issues we want to obtain into the report.
|
||||||
Default value is <code>1000</code>.
|
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
<code>1000</code>.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>maven.jira.component</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
Sets the component(s) of the project you want to limit your report to.
|
||||||
|
Multiple components can be separated by commas (such as <code>10011,10012</code>).
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
empty, meaning all components.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>maven.jira.status</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
Sets the status(es) of the project you want to limit your report to.
|
||||||
|
Valid statuses are: <code>Open, In Progress, Reopened, Resolved and Closed</code>.
|
||||||
|
Multiple values can be separated by commas.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
<code>Open, In Progress, Reopened</code>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>maven.jira.resolution</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
Sets the resolution(s) of the project you want to limit your report to.
|
||||||
|
Valid statuses are: <code>Unresolved, Fixed, Won't Fix, Duplicate, Incomplete, Cannot Reproduce</code>.
|
||||||
|
Multiple values can be separated by commas.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
<code>Unresolved</code>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>maven.jira.priority</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
Sets the priority(s) of the project you want to limit your report to.
|
||||||
|
Valid statuses are: <code>Blocker, Critical, Major, Minor, Trivial</code>.
|
||||||
|
Multiple values can be separated by commas.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
empty, meaning any priority.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>maven.jira.filter</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
Defines the filter parameters to restrict the result issues from Jira.
|
||||||
|
The filter parameters property must use the same format of url parameters from the Jira search url.
|
||||||
|
Example: <code>status=1&resolution=-1&priority=1&priority=3&priority=4&sorter/field=issuekey&sorter/order=DESC</code>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<b>Note</b>: This string should not contain the parameters <code>pid</code>, <code>tempMax</code>
|
||||||
|
and <code>view</code>.<br/>
|
||||||
|
<b>Note</b>: This filter overrides the status, resolution, priority and component properties.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>maven.jira.jiraUser</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
Defines the jira username for authentication into a private Jira instalation.<br/>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>maven.jira.jiraPassword</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
Defines the jira password for authentication into a private Jira instalation.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>maven.jira.webUser</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
Defines the http user for basic authentication into the Jira webserver.<br/>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>maven.jira.webPassword</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
Defines the http password for basic authentication into the Jira webserver.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user