<?xml version="1.0" encoding="UTF-8"?>
<?asciidoc-toc maxdepth="2"?>
<?asciidoc-numbered?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en">
<info>
<title>Gradle Plugin for Editing Atlassian Jira Issues</title>
<date>2020-06-09</date>
</info>
<note>
<simpara>Version 6.0 of this plugin will only work with Gradle 6 and JDK 8.</simpara>
</note>
<section xml:id="asciidocsummary">
<title>Summary</title>
<simpara>This plugin iterates over a list of Atlassian JIRA issues and edit the defined field with a given value. The list of
issues is defined by an line-based text file. It works for example together with the result of the task 'createChangelog'
applied by <link xl:href="https://github.com/IntershopCommunicationsAG/scmversion-gradle-plugin">'SCM Version Plugin'</link></simpara>
</section>
<section xml:id="asciidocusage">
<title>Usage</title>
<simpara>To use the JiraConnector plugin, include the following in your build script:</simpara>
<details open>
<summary>Groovy</summary>
<formalpara>
<title>build.gradle</title>
<para>
<programlisting language="groovy" linenumbering="unnumbered">plugins {
    id 'com.intershop.gradle.jiraconnector' version '6.3.0'
}

jiraConnector {
    server {
        baseURL = 'https://jira.host.com/jira'
        username = 'JIRAuser'
        password = 'secret'
    }

    linePattern = '3\\+.*'

    fieldName = 'Fixed Version/s'

    fieldValue = "${project.name}/${project.version}"

    versionMessage = 'version created by jiraconnector plugin'

    issueFile = tasks.createFile.outputs.files.singleFile
}</programlisting>
</para>
</formalpara>
</details>
<details>
<summary>Kotlin</summary>
<formalpara>
<title>build.gradle.kts</title>
<para>
<programlisting language="kotlin" linenumbering="unnumbered">plugins {
    id("com.intershop.gradle.jiraconnector") version "6.3.0"
}

jiraConnector {
    server {
        baseURL = "https://jira.host.com/jira"
        username = "JIRAuser"
        password = "secret"
    }

    linePattern = "3\\+.*"

    fieldName = "Fixed Version/s"

    fieldValue = "${project.name}/${project.version}"

    versionMessage = "version created by jiraconnector plugin"

    issueFile = tasks["createFile"].outputs.files.singleFile
}</programlisting>
</para>
</formalpara>
</details>
<simpara>This configuration add the field value <literal>${project.name}/${project.version}</literal> to the field <literal>Fixed Version/s</literal> for Jira issues, which are listed in the issue file.
If a Jira version is not available in the list, the version will be created, sorted and previous milestone versions will be merged to the new version if configured.</simpara>
</section>
<section xml:id="asciidoctasks">
<title>Tasks</title>
<simpara>The Jira connector plugin adds two tasks to the project.</simpara>
<informaltable frame="all" rowsep="1" colsep="1">
<?dbhtml table-width="95%"?>
<?dbfo table-width="95%"?>
<?dblatex table-width="95%"?>
<tgroup cols="3">
<colspec colname="col_1" colwidth="100.9375*"/>
<colspec colname="col_2" colwidth="121.125*"/>
<colspec colname="col_3" colwidth="181.6875*"/>
<thead>
<row>
<entry align="left" valign="top">Task name</entry>
<entry align="left" valign="top">Type</entry>
<entry align="left" valign="top">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara>correctVersionList</simpara></entry>
<entry align="left" valign="top"><simpara>com.intershop.gradle.jiraconnector.task.CorrectVersionList</simpara></entry>
<entry align="left" valign="top"><simpara>If the replacements list is configured, versions with component names ("component/&lt;version&gt;')
are changed so that the component name is replaced according to the list. After this step, it sorts the list of Jira versions of a specified project.
This task requires a parameter 'jiraProjectKey', this is the Jira project key for the version list (look for "versions" in the project configuration overview page).</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara>setIssueField</simpara></entry>
<entry align="left" valign="top"><simpara>com.intershop.gradle.jiraconnector.task.SetIssueField</simpara></entry>
<entry align="left" valign="top"><simpara>The configured issue file will be parsed for issues and the configured field of these Jira issues will be updated with the configured information.</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
<section xml:id="asciidocexample">
<title>Example</title>
<simpara>This build file and command line will correct the version list of the projekt with key "PRJKEY".</simpara>
<formalpara>
<title>build.gradle</title>
<para>
<programlisting language="groovy" linenumbering="unnumbered">plugins {
    id 'com.intershop.gradle.jiraconnector'
}

jiraConnector {
    jira {
        baseURL = 'https://jira.host.com/jira'
        username = 'JIRAuser'
        password = 'secret'
    }
    replacements = ['old_componentname_1':'new_name_1', 'old_componentname_2':'new_name_2']
}</programlisting>
</para>
</formalpara>
<formalpara>
<title>command line</title>
<para>
<screen>./gradlew correctVersionList --jiraProjectKey=PRJKEY</screen>
</para>
</formalpara>
</section>
</section>
<section xml:id="asciidocproject-extension-jiraconnector">
<title>Project Extension 'jiraConnector'</title>
<simpara>This plugin adds an extension <emphasis role="strong"><literal>jiraConnector</literal></emphasis> to the project.</simpara>
<section xml:id="asciidocmethods">
<title>Methods</title>
<informaltable frame="all" rowsep="1" colsep="1">
<?dbhtml table-width="95%"?>
<?dbfo table-width="95%"?>
<?dblatex table-width="95%"?>
<tgroup cols="3">
<colspec colname="col_1" colwidth="80.75*"/>
<colspec colname="col_2" colwidth="60.5625*"/>
<colspec colname="col_3" colwidth="262.4375*"/>
<thead>
<row>
<entry align="left" valign="top">Method</entry>
<entry align="left" valign="top">Values</entry>
<entry align="left" valign="top">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">server</emphasis></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>This contains the Atlassian Jira server connection configuration.</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section xml:id="asciidocproperties">
<title>Properties</title>
<informaltable frame="all" rowsep="1" colsep="1">
<?dbhtml table-width="95%"?>
<?dbfo table-width="95%"?>
<?dblatex table-width="95%"?>
<tgroup cols="5">
<colspec colname="col_1" colwidth="68.6375*"/>
<colspec colname="col_2" colwidth="68.6375*"/>
<colspec colname="col_3" colwidth="68.6375*"/>
<colspec colname="col_4" colwidth="68.6375*"/>
<colspec colname="col_5" colwidth="129.2*"/>
<thead>
<row>
<entry align="left" valign="top">Property</entry>
<entry align="left" valign="top">Type</entry>
<entry align="left" valign="top">Default value</entry>
<entry align="left" valign="top">Values</entry>
<entry align="left" valign="top">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">versionMessage</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara>'added by intershop-jiraconnector-plugin'</simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>If the specified field a version field, it is necessary to add a version if this is not available.<?asciidoc-br?>
It is necessary to specify a message for this operation.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">fieldName</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>Field name in Jira</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">fieldValue</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>Value for the field</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">fieldPattern</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara>'(.*)'</simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>Pattern for field value, first group of matcher is used for setting</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">mergeMilestoneVersions</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>boolean</literal></simpara></entry>
<entry align="left" valign="top"><simpara>true</simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>Previous milestone version will be merged, when new Jira versions will be added if this property is set to true.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">replacements</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>Map</simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>['old':'new']</simpara></entry>
<entry align="left" valign="top"><simpara>Map with old and new values vor component names in Jira version list with versions like componentname/1.0.0.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">issueFile</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>File</literal></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>Line-Based text file with Jira issues</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">linePattern</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"><simpara>'.*'</simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>This is the filter pattern for lines which should be scanned in the <emphasis role="strong">issueFile</emphasis>.</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
<section xml:id="asciidocexamples-for-issuefile">
<title>Examples for 'issueFile'</title>
<section xml:id="asciidoctext-file-asciidoc-format">
<title>Text file - AsciiDoc format</title>
<screen linenumbering="unnumbered">= Change Log for 2.0.0

This list contains changes since version 1.0.0. +
Created: Sun Feb 21 17:11:48 CET 2016

[cols="5%,5%,90%", width="95%", options="header"]
|===
3+| JIRA-1234 change on master (e6c62c43)
| | M |  gradle.properties
3+| remove unnecessary files (a2da48ad)
| | D | branches/FB_1.0.0-JIRA-4567/wrapper/gradle-wrapper.jar
|===</screen>
<simpara>With the line pattern '3\+.*' (see example configuration) only lines are evaluated, beginning with '3+'. The line 'branches/FB_1.0.0-JIRA-4567/wrapper/gradle-wrapper.jar'
will be not evaluated and 'JIRA-4567' will be not part of the issue list.</simpara>
</section>
<section xml:id="asciidoctext-file">
<title>Text file</title>
<screen linenumbering="unnumbered">JIRA-1234: jira issue description
JIRA-5678,JIRA-6789: other jira issue descriptions</screen>
</section>
<section xml:id="asciidocxml-file">
<title>XML file</title>
<programlisting language="xml" linenumbering="unnumbered">&lt;xml&gt;
    &lt;issue&gt;JIRA-1234&lt;/issue&gt;
    &lt;descr&gt;jira issue description&lt;/descr&gt;
    &lt;issue&gt;JIRA-5678&lt;/issue&gt;
    &lt;descr&gt;an other jira issue description&lt;/descr&gt;
&lt;/xml&gt;</programlisting>
</section>
</section>
<section xml:id="asciidocexample-configuration-for-replacements">
<title>Example configuration for 'replacements'</title>
<formalpara>
<title>build.gradle</title>
<para>
<programlisting language="groovy" linenumbering="unnumbered">plugins {
    id 'com.intershop.gradle.jiraconnector'
}

jiraConnector {
    jira {
        baseURL = 'https://jira.host.com/jira'
        username = 'JIRAuser'
        password = 'secret'
    }

    replacements = ['old_componentname_1':'new_name_1', 'old_componentname_2':'new_name_2']
}</programlisting>
</para>
</formalpara>
<simpara>Versions like 'old_componentname_1/1.0.0' will be changed to 'new_name_1/1.0.0'.</simpara>
</section>
</section>
<section xml:id="asciidocserver-connection-configuration-server">
<title><anchor xml:id="server" xreflabel="[server]"/>Server connection configuration 'Server'</title>
<informaltable frame="all" rowsep="1" colsep="1">
<?dbhtml table-width="95%"?>
<?dbfo table-width="95%"?>
<?dblatex table-width="95%"?>
<tgroup cols="4">
<colspec colname="col_1" colwidth="68.6375*"/>
<colspec colname="col_2" colwidth="68.6375*"/>
<colspec colname="col_3" colwidth="60.5625*"/>
<colspec colname="col_4" colwidth="205.9125*"/>
<thead>
<row>
<entry align="left" valign="top">Property</entry>
<entry align="left" valign="top">Type</entry>
<entry align="left" valign="top">Default value</entry>
<entry align="left" valign="top">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">baseURL</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>Atlassian Jira base URL</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">username</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>Username</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">password</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>String</literal></simpara></entry>
<entry align="left" valign="top"></entry>
<entry align="left" valign="top"><simpara>Password</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">socketTimeout</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>int</literal></simpara></entry>
<entry align="left" valign="top"><simpara>3</simpara></entry>
<entry align="left" valign="top"><simpara>Jira rest configuration: Socket time out in minutes</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">requestTimeout</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><literal>int</literal></simpara></entry>
<entry align="left" valign="top"><simpara>3</simpara></entry>
<entry align="left" valign="top"><simpara>Jira rest configuration: Request time out in minutes</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
</section>
<section xml:id="asciidocenvironment-configuration">
<title>Environment Configuration</title>
<simpara>The behaviour of this plugin can be also controlled by environment variables, so that the plugin can be applied to the project without exceptions.</simpara>
<informaltable frame="all" rowsep="1" colsep="1">
<?dbhtml table-width="95%"?>
<?dbfo table-width="95%"?>
<?dblatex table-width="95%"?>
<tgroup cols="3">
<colspec colname="col_1" colwidth="69.3307*"/>
<colspec colname="col_2" colwidth="69.3307*"/>
<colspec colname="col_3" colwidth="265.0885*"/>
<thead>
<row>
<entry align="left" valign="top">System variable or Java system property</entry>
<entry align="left" valign="top">Project property</entry>
<entry align="left" valign="top">Description</entry>
</row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">JIRABASEURL</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">jiraBaseURL</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>The base url of Atlassian Jira, e.g. <link xl:href="http://jira/jira">http://jira/jira</link></simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">JIRAUSERNAME</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">jiraUserName</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>The username with the correct role/permissions for editing issues</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">JIRAUSERPASSWD</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">jiraUserPASSWD</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>The password of the user.</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">SOCKET_TIMEOUT</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">socketTimeout</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>Jira rest configuration: Socket time out in minutes</simpara></entry>
</row>
<row>
<entry align="left" valign="top"><simpara><emphasis role="strong">REQUEST_TIMEOUT</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara><emphasis role="strong">requestTimeout</emphasis></simpara></entry>
<entry align="left" valign="top"><simpara>Jira rest configuration: Request time out in minutes</simpara></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section xml:id="asciidoclicense">
<title>License</title>
<simpara>Copyright 2014-2020 Intershop Communications.</simpara>
<simpara>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at</simpara>
<simpara><link xl:href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</link></simpara>
<simpara>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.</simpara>
</section>
</article>