| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 6 |
<meta name="generator" content="Docutils 0.21.2: https://docutils.sourceforge.io/" /> |
| 7 |
<title>bugzilla</title> |
| 8 |
<link rel="stylesheet" href="../style.css" type="text/css" /> |
| 9 |
</head> |
| 10 |
<body> |
| 11 |
<div class="document" id="bugzilla"> |
| 12 |
<span id="ext-bugzilla"></span> |
| 13 |
<h1 class="title">bugzilla</h1> |
| 14 |
|
| 15 |
<div class="contents htmlonly topic" id="contents"> |
| 16 |
<p class="topic-title"><a class="reference internal" href="#top">Contents</a></p> |
| 17 |
<ul class="simple"> |
| 18 |
<li><a class="reference internal" href="#description" id="toc-entry-1">Description</a></li> |
| 19 |
</ul> |
| 20 |
</div> |
| 21 |
<p>hooks for integrating with the Bugzilla bug tracker</p> |
| 22 |
<div class="section" id="description"> |
| 23 |
<h1><a class="toc-backref" href="#contents">Description</a></h1> |
| 24 |
<p>This hook extension adds comments on bugs in Bugzilla when changesets |
| 25 |
that refer to bugs by Bugzilla ID are seen. The comment is formatted using |
| 26 |
the Mercurial template mechanism.</p> |
| 27 |
<p>The bug references can optionally include an update for Bugzilla of the |
| 28 |
hours spent working on the bug. Bugs can also be marked fixed.</p> |
| 29 |
<p>Four basic modes of access to Bugzilla are provided:</p> |
| 30 |
<ol class="arabic simple"> |
| 31 |
<li>Access via the Bugzilla REST-API. Requires bugzilla 5.0 or later.</li> |
| 32 |
<li>Access via the Bugzilla XMLRPC interface. Requires Bugzilla 3.4 or later.</li> |
| 33 |
<li>Check data via the Bugzilla XMLRPC interface and submit bug change |
| 34 |
via email to Bugzilla email interface. Requires Bugzilla 3.4 or later.</li> |
| 35 |
<li>Writing directly to the Bugzilla database. Only Bugzilla installations |
| 36 |
using MySQL are supported. Requires Python MySQLdb.</li> |
| 37 |
</ol> |
| 38 |
<p>Writing directly to the database is susceptible to schema changes, and |
| 39 |
relies on a Bugzilla contrib script to send out bug change |
| 40 |
notification emails. This script runs as the user running Mercurial, |
| 41 |
must be run on the host with the Bugzilla install, and requires |
| 42 |
permission to read Bugzilla configuration details and the necessary |
| 43 |
MySQL user and password to have full access rights to the Bugzilla |
| 44 |
database. For these reasons this access mode is now considered |
| 45 |
deprecated, and will not be updated for new Bugzilla versions going |
| 46 |
forward. Only adding comments is supported in this access mode.</p> |
| 47 |
<p>Access via XMLRPC needs a Bugzilla username and password to be specified |
| 48 |
in the configuration. Comments are added under that username. Since the |
| 49 |
configuration must be readable by all Mercurial users, it is recommended |
| 50 |
that the rights of that user are restricted in Bugzilla to the minimum |
| 51 |
necessary to add comments. Marking bugs fixed requires Bugzilla 4.0 and later.</p> |
| 52 |
<p>Access via XMLRPC/email uses XMLRPC to query Bugzilla, but sends |
| 53 |
email to the Bugzilla email interface to submit comments to bugs. |
| 54 |
The From: address in the email is set to the email address of the Mercurial |
| 55 |
user, so the comment appears to come from the Mercurial user. In the event |
| 56 |
that the Mercurial user email is not recognized by Bugzilla as a Bugzilla |
| 57 |
user, the email associated with the Bugzilla username used to log into |
| 58 |
Bugzilla is used instead as the source of the comment. Marking bugs fixed |
| 59 |
works on all supported Bugzilla versions.</p> |
| 60 |
<p>Access via the REST-API needs either a Bugzilla username and password |
| 61 |
or an apikey specified in the configuration. Comments are made under |
| 62 |
the given username or the user associated with the apikey in Bugzilla.</p> |
| 63 |
<p>Configuration items common to all access modes:</p> |
| 64 |
<dl class="docutils"> |
| 65 |
<dt>bugzilla.version</dt> |
| 66 |
<dd><p class="first">The access type to use. Values recognized are:</p> |
| 67 |
<table class="last docutils field-list" frame="void" rules="none"> |
| 68 |
<col class="field-name" /> |
| 69 |
<col class="field-body" /> |
| 70 |
<tbody valign="top"> |
| 71 |
<tr class="field"><th class="field-name"><tt class="docutils literal">restapi</tt>:</th><td class="field-body">Bugzilla REST-API, Bugzilla 5.0 and later.</td> |
| 72 |
</tr> |
| 73 |
<tr class="field"><th class="field-name"><tt class="docutils literal">xmlrpc</tt>:</th><td class="field-body">Bugzilla XMLRPC interface.</td> |
| 74 |
</tr> |
| 75 |
<tr class="field"><th class="field-name"><tt class="docutils literal">xmlrpc+email</tt>:</th><td class="field-body">Bugzilla XMLRPC and email interfaces.</td> |
| 76 |
</tr> |
| 77 |
<tr class="field"><th class="field-name"><tt class="docutils literal">3.0</tt>:</th><td class="field-body">MySQL access, Bugzilla 3.0 and later.</td> |
| 78 |
</tr> |
| 79 |
<tr class="field"><th class="field-name"><tt class="docutils literal">2.18</tt>:</th><td class="field-body">MySQL access, Bugzilla 2.18 and up to but not |
| 80 |
including 3.0.</td> |
| 81 |
</tr> |
| 82 |
<tr class="field"><th class="field-name"><tt class="docutils literal">2.16</tt>:</th><td class="field-body">MySQL access, Bugzilla 2.16 and up to but not |
| 83 |
including 2.18.</td> |
| 84 |
</tr> |
| 85 |
</tbody> |
| 86 |
</table> |
| 87 |
</dd> |
| 88 |
<dt>bugzilla.regexp</dt> |
| 89 |
<dd>Regular expression to match bug IDs for update in changeset commit message. |
| 90 |
It must contain one "()" named group <tt class="docutils literal"><ids></tt> containing the bug |
| 91 |
IDs separated by non-digit characters. It may also contain |
| 92 |
a named group <tt class="docutils literal"><hours></tt> with a floating-point number giving the |
| 93 |
hours worked on the bug. If no named groups are present, the first |
| 94 |
"()" group is assumed to contain the bug IDs, and work time is not |
| 95 |
updated. The default expression matches <tt class="docutils literal">Bug 1234</tt>, <tt class="docutils literal">Bug no. 1234</tt>, |
| 96 |
<tt class="docutils literal">Bug number 1234</tt>, <tt class="docutils literal">Bugs 1234,5678</tt>, <tt class="docutils literal">Bug 1234 and 5678</tt> and |
| 97 |
variations thereof, followed by an hours number prefixed by <tt class="docutils literal">h</tt> or |
| 98 |
<tt class="docutils literal">hours</tt>, e.g. <tt class="docutils literal">hours 1.5</tt>. Matching is case insensitive.</dd> |
| 99 |
<dt>bugzilla.fixregexp</dt> |
| 100 |
<dd>Regular expression to match bug IDs for marking fixed in changeset |
| 101 |
commit message. This must contain a "()" named group <tt class="docutils literal"><ids>` containing |
| 102 |
the bug IDs separated by <span class="pre">non-digit</span> characters. It may also contain |
| 103 |
a named group <span class="pre">``<hours></span></tt> with a floating-point number giving the |
| 104 |
hours worked on the bug. If no named groups are present, the first |
| 105 |
"()" group is assumed to contain the bug IDs, and work time is not |
| 106 |
updated. The default expression matches <tt class="docutils literal">Fixes 1234</tt>, <tt class="docutils literal">Fixes bug 1234</tt>, |
| 107 |
<tt class="docutils literal">Fixes bugs 1234,5678</tt>, <tt class="docutils literal">Fixes 1234 and 5678</tt> and |
| 108 |
variations thereof, followed by an hours number prefixed by <tt class="docutils literal">h</tt> or |
| 109 |
<tt class="docutils literal">hours</tt>, e.g. <tt class="docutils literal">hours 1.5</tt>. Matching is case insensitive.</dd> |
| 110 |
<dt>bugzilla.fixstatus</dt> |
| 111 |
<dd>The status to set a bug to when marking fixed. Default <tt class="docutils literal">RESOLVED</tt>.</dd> |
| 112 |
<dt>bugzilla.fixresolution</dt> |
| 113 |
<dd>The resolution to set a bug to when marking fixed. Default <tt class="docutils literal">FIXED</tt>.</dd> |
| 114 |
<dt>bugzilla.style</dt> |
| 115 |
<dd>The style file to use when formatting comments.</dd> |
| 116 |
<dt>bugzilla.template</dt> |
| 117 |
<dd><p class="first">Template to use when formatting comments. Overrides style if |
| 118 |
specified. In addition to the usual Mercurial keywords, the |
| 119 |
extension specifies:</p> |
| 120 |
<table class="docutils field-list" frame="void" rules="none"> |
| 121 |
<col class="field-name" /> |
| 122 |
<col class="field-body" /> |
| 123 |
<tbody valign="top"> |
| 124 |
<tr class="field"><th class="field-name"><tt class="docutils literal">{bug}</tt>:</th><td class="field-body">The Bugzilla bug ID.</td> |
| 125 |
</tr> |
| 126 |
<tr class="field"><th class="field-name"><tt class="docutils literal">{root}</tt>:</th><td class="field-body">The full pathname of the Mercurial repository.</td> |
| 127 |
</tr> |
| 128 |
<tr class="field"><th class="field-name"><tt class="docutils literal">{webroot}</tt>:</th><td class="field-body">Stripped pathname of the Mercurial repository.</td> |
| 129 |
</tr> |
| 130 |
<tr class="field"><th class="field-name"><tt class="docutils literal">{hgweb}</tt>:</th><td class="field-body">Base URL for browsing Mercurial repositories.</td> |
| 131 |
</tr> |
| 132 |
</tbody> |
| 133 |
</table> |
| 134 |
<p class="last">Default <tt class="docutils literal">changeset {node|short} in repo {root} refers to bug |
| 135 |
<span class="pre">{bug}.\ndetails:\n\t{desc|tabindent}</span></tt></p> |
| 136 |
</dd> |
| 137 |
<dt>bugzilla.strip</dt> |
| 138 |
<dd>The number of path separator characters to strip from the front of |
| 139 |
the Mercurial repository path (<tt class="docutils literal">{root}</tt> in templates) to produce |
| 140 |
<tt class="docutils literal">{webroot}</tt>. For example, a repository with <tt class="docutils literal">{root}</tt> |
| 141 |
<tt class="docutils literal"><span class="pre">/var/local/my-project</span></tt> with a strip of 2 gives a value for |
| 142 |
<tt class="docutils literal">{webroot}</tt> of <tt class="docutils literal"><span class="pre">my-project</span></tt>. Default 0.</dd> |
| 143 |
<dt>web.baseurl</dt> |
| 144 |
<dd>Base URL for browsing Mercurial repositories. Referenced from |
| 145 |
templates as <tt class="docutils literal">{hgweb}</tt>.</dd> |
| 146 |
</dl> |
| 147 |
<p>Configuration items common to XMLRPC+email and MySQL access modes:</p> |
| 148 |
<dl class="docutils"> |
| 149 |
<dt>bugzilla.usermap</dt> |
| 150 |
<dd><p class="first">Path of file containing Mercurial committer email to Bugzilla user email |
| 151 |
mappings. If specified, the file should contain one mapping per |
| 152 |
line:</p> |
| 153 |
<pre class="literal-block"> |
| 154 |
committer = Bugzilla user |
| 155 |
</pre> |
| 156 |
<p class="last">See also the <tt class="docutils literal">[usermap]</tt> section.</p> |
| 157 |
</dd> |
| 158 |
</dl> |
| 159 |
<p>The <tt class="docutils literal">[usermap]</tt> section is used to specify mappings of Mercurial |
| 160 |
committer email to Bugzilla user email. See also <tt class="docutils literal">bugzilla.usermap</tt>. |
| 161 |
Contains entries of the form <tt class="docutils literal">committer = Bugzilla user</tt>.</p> |
| 162 |
<p>XMLRPC and REST-API access mode configuration:</p> |
| 163 |
<dl class="docutils"> |
| 164 |
<dt>bugzilla.bzurl</dt> |
| 165 |
<dd>The base URL for the Bugzilla installation. |
| 166 |
Default <tt class="docutils literal"><span class="pre">http://localhost/bugzilla</span></tt>.</dd> |
| 167 |
<dt>bugzilla.user</dt> |
| 168 |
<dd>The username to use to log into Bugzilla via XMLRPC. Default |
| 169 |
<tt class="docutils literal">bugs</tt>.</dd> |
| 170 |
<dt>bugzilla.password</dt> |
| 171 |
<dd>The password for Bugzilla login.</dd> |
| 172 |
</dl> |
| 173 |
<p>REST-API access mode uses the options listed above as well as:</p> |
| 174 |
<dl class="docutils"> |
| 175 |
<dt>bugzilla.apikey</dt> |
| 176 |
<dd>An apikey generated on the Bugzilla instance for api access. |
| 177 |
Using an apikey removes the need to store the user and password |
| 178 |
options.</dd> |
| 179 |
</dl> |
| 180 |
<p>XMLRPC+email access mode uses the XMLRPC access mode configuration items, |
| 181 |
and also:</p> |
| 182 |
<dl class="docutils"> |
| 183 |
<dt>bugzilla.bzemail</dt> |
| 184 |
<dd>The Bugzilla email address.</dd> |
| 185 |
</dl> |
| 186 |
<p>In addition, the Mercurial email settings must be configured. See the |
| 187 |
documentation in hgrc(5), sections <tt class="docutils literal">[email]</tt> and <tt class="docutils literal">[smtp]</tt>.</p> |
| 188 |
<p>MySQL access mode configuration:</p> |
| 189 |
<dl class="docutils"> |
| 190 |
<dt>bugzilla.host</dt> |
| 191 |
<dd>Hostname of the MySQL server holding the Bugzilla database. |
| 192 |
Default <tt class="docutils literal">localhost</tt>.</dd> |
| 193 |
<dt>bugzilla.db</dt> |
| 194 |
<dd>Name of the Bugzilla database in MySQL. Default <tt class="docutils literal">bugs</tt>.</dd> |
| 195 |
<dt>bugzilla.user</dt> |
| 196 |
<dd>Username to use to access MySQL server. Default <tt class="docutils literal">bugs</tt>.</dd> |
| 197 |
<dt>bugzilla.password</dt> |
| 198 |
<dd>Password to use to access MySQL server.</dd> |
| 199 |
<dt>bugzilla.timeout</dt> |
| 200 |
<dd>Database connection timeout (seconds). Default 5.</dd> |
| 201 |
<dt>bugzilla.bzuser</dt> |
| 202 |
<dd>Fallback Bugzilla user name to record comments with, if changeset |
| 203 |
committer cannot be found as a Bugzilla user.</dd> |
| 204 |
<dt>bugzilla.bzdir</dt> |
| 205 |
<dd>Bugzilla install directory. Used by default notify. Default |
| 206 |
<tt class="docutils literal">/var/www/html/bugzilla</tt>.</dd> |
| 207 |
<dt>bugzilla.notify</dt> |
| 208 |
<dd>The command to run to get Bugzilla to send bug change notification |
| 209 |
emails. Substitutes from a map with 3 keys, <tt class="docutils literal">bzdir</tt>, <tt class="docutils literal">id</tt> (bug |
| 210 |
id) and <tt class="docutils literal">user</tt> (committer bugzilla email). Default depends on |
| 211 |
version; from 2.18 it is "cd %(bzdir)s && perl -T |
| 212 |
contrib/sendbugmail.pl %(id)s %(user)s".</dd> |
| 213 |
</dl> |
| 214 |
<p>Activating the extension:</p> |
| 215 |
<pre class="literal-block"> |
| 216 |
[extensions] |
| 217 |
bugzilla = |
| 218 |
|
| 219 |
[hooks] |
| 220 |
# run bugzilla hook on every change pulled or pushed in here |
| 221 |
incoming.bugzilla = python:hgext.bugzilla.hook |
| 222 |
</pre> |
| 223 |
<p>Example configurations:</p> |
| 224 |
<p>XMLRPC example configuration. This uses the Bugzilla at |
| 225 |
<tt class="docutils literal"><span class="pre">http://my-project.org/bugzilla</span></tt>, logging in as user |
| 226 |
<tt class="docutils literal"><span class="pre">bugmail@my-project.org</span></tt> with password <tt class="docutils literal">plugh</tt>. It is used with a |
| 227 |
collection of Mercurial repositories in <tt class="docutils literal">/var/local/hg/repos/</tt>, |
| 228 |
with a web interface at <tt class="docutils literal"><span class="pre">http://my-project.org/hg</span></tt>.</p> |
| 229 |
<pre class="literal-block"> |
| 230 |
[bugzilla] |
| 231 |
bzurl=http://my-project.org/bugzilla |
| 232 |
user=bugmail@my-project.org |
| 233 |
password=plugh |
| 234 |
version=xmlrpc |
| 235 |
template=Changeset {node|short} in {root|basename}. |
| 236 |
{hgweb}/{webroot}/rev/{node|short}\n |
| 237 |
{desc}\n |
| 238 |
strip=5 |
| 239 |
|
| 240 |
[web] |
| 241 |
baseurl=http://my-project.org/hg |
| 242 |
</pre> |
| 243 |
<p>XMLRPC+email example configuration. This uses the Bugzilla at |
| 244 |
<tt class="docutils literal"><span class="pre">http://my-project.org/bugzilla</span></tt>, logging in as user |
| 245 |
<tt class="docutils literal"><span class="pre">bugmail@my-project.org</span></tt> with password <tt class="docutils literal">plugh</tt>. It is used with a |
| 246 |
collection of Mercurial repositories in <tt class="docutils literal">/var/local/hg/repos/</tt>, |
| 247 |
with a web interface at <tt class="docutils literal"><span class="pre">http://my-project.org/hg</span></tt>. Bug comments |
| 248 |
are sent to the Bugzilla email address |
| 249 |
<tt class="docutils literal"><span class="pre">bugzilla@my-project.org</span></tt>.</p> |
| 250 |
<pre class="literal-block"> |
| 251 |
[bugzilla] |
| 252 |
bzurl=http://my-project.org/bugzilla |
| 253 |
user=bugmail@my-project.org |
| 254 |
password=plugh |
| 255 |
version=xmlrpc+email |
| 256 |
bzemail=bugzilla@my-project.org |
| 257 |
template=Changeset {node|short} in {root|basename}. |
| 258 |
{hgweb}/{webroot}/rev/{node|short}\n |
| 259 |
{desc}\n |
| 260 |
strip=5 |
| 261 |
|
| 262 |
[web] |
| 263 |
baseurl=http://my-project.org/hg |
| 264 |
|
| 265 |
[usermap] |
| 266 |
user@emaildomain.com=user.name@bugzilladomain.com |
| 267 |
</pre> |
| 268 |
<p>MySQL example configuration. This has a local Bugzilla 3.2 installation |
| 269 |
in <tt class="docutils literal"><span class="pre">/opt/bugzilla-3.2</span></tt>. The MySQL database is on <tt class="docutils literal">localhost</tt>, |
| 270 |
the Bugzilla database name is <tt class="docutils literal">bugs</tt> and MySQL is |
| 271 |
accessed with MySQL username <tt class="docutils literal">bugs</tt> password <tt class="docutils literal">XYZZY</tt>. It is used |
| 272 |
with a collection of Mercurial repositories in <tt class="docutils literal">/var/local/hg/repos/</tt>, |
| 273 |
with a web interface at <tt class="docutils literal"><span class="pre">http://my-project.org/hg</span></tt>.</p> |
| 274 |
<pre class="literal-block"> |
| 275 |
[bugzilla] |
| 276 |
host=localhost |
| 277 |
password=XYZZY |
| 278 |
version=3.0 |
| 279 |
bzuser=unknown@domain.com |
| 280 |
bzdir=/opt/bugzilla-3.2 |
| 281 |
template=Changeset {node|short} in {root|basename}. |
| 282 |
{hgweb}/{webroot}/rev/{node|short}\n |
| 283 |
{desc}\n |
| 284 |
strip=5 |
| 285 |
|
| 286 |
[web] |
| 287 |
baseurl=http://my-project.org/hg |
| 288 |
|
| 289 |
[usermap] |
| 290 |
user@emaildomain.com=user.name@bugzilladomain.com |
| 291 |
</pre> |
| 292 |
<p>All the above add a comment to the Bugzilla bug record of the form:</p> |
| 293 |
<pre class="literal-block"> |
| 294 |
Changeset 3b16791d6642 in repository-name. |
| 295 |
http://my-project.org/hg/repository-name/rev/3b16791d6642 |
| 296 |
|
| 297 |
Changeset commit comment. Bug 1234. |
| 298 |
</pre> |
| 299 |
</div> |
| 300 |
</div> |
| 301 |
</body> |
| 302 |
</html> |