<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://www.urbancode.com/PluginXMLSchema_v1" 
   xmlns:server="http://www.urbancode.com/PluginServerXMLSchema_v1"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <header>
    <identifier id="com.urbancode.air.plugin.clearquest" name="ClearQuest" version="3"/>
    <description>
      ClearQuest provides change tracking, process automation, reporting and lifecycle traceability for better visibility and control of the software development lifecycle.
    </description>
    <tag>Quality/Issue Tracking/ClearQuest</tag>
    <server:plugin-type>Automation</server:plugin-type>
  </header>
  
  
  <!-- ==================================== -->
  <!--   STEPS                              -->
  <!-- ==================================== -->
  <step-type name="Add Comment">
    <description>Add Comments from the current changelog to matching ClearQuest Defects</description>
    <properties>
      <property name="defectId" required="true">
        <property-ui type="textBox"
                     label="Defect ID"
                     description="The ID of the defect to place the comment on."/>
      </property>
      <property name="comment" required="true">
        <property-ui type="textAreaBox"
                     label="Comment"
                     description="The content of the comment."/>
      </property>
      <property name="automation" required="true">
        <property-ui type="automationPropSheetRef"
                     label="ClearQuest Server"
                     description="The ClearQuest server. This may be configured under the System tab."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/httpcore.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/httpmime.jar:lib/HttpComponents-Util.jar:lib/CommonsUtil.jar:lib/commons-logging.jar:lib/commons-codec.jar:lib/log4j.jar"/>
      <arg file="add-comment.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
  
  
  <step-type name="Publish Defect Report">
    <description>Create a Report of ClearQuest defects from the current changelog</description>
    <properties>
      <property name="defectIdPattern" required="true">
        <property-ui type="textBox"
                     label="Defect ID Pattern"
                     description="This is a regular expression to locate ClearQuest-defect ids within
                     changelog comments.  You may add '()' around the portion of the pattern
                     which identifies the actual Issue ID. The pattern 'TST-[0-9]+' would match
                     (returning the same string as issue ids) 'TST-1' and 'TST-932415', but not
                     match 'TST-a', 'TST-', or 'TST.1'. The pattern 'Issue:\[(TST-[0-9]+)\]'
                     would match 'Issue:[TST-1]' using issue id TST-1"/>
      </property>
      <property name="automation" required="true">
        <property-ui type="automationPropSheetRef"
                     label="ClearQuest Server"
                     description="The ClearQuest server. This may be configured under the System tab."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/httpcore.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/httpmime.jar:lib/HttpComponents-Util.jar:lib/CommonsUtil.jar:lib/commons-logging.jar:lib/commons-codec.jar:lib/log4j.jar"/>
      <arg file="publish-report.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
  
  
  <step-type name="Create Defect">
    <description>Create a new defect in a ClearQuest Defect Tracker</description>
    <properties>
      <property name="headline" required="true">
        <property-ui type="textBox"
                     label="Headline"
                     description="The headline of the defect."/>
      </property>
      <property name="severity" required="true">
        <property-ui type="textBox"
                     label="Severity"
                     description="The severity level of the defect."/>
      </property>
      <property name="projectName">
        <property-ui type="textBox"
                     label="ClearQuest Project Name"
                     description="The name of the project in ClearQuest."/>
      </property>
      <property name="priority">
        <property-ui type="textBox"
                     label="Priority"
                     description="The priority level of the defect."/>
      </property>
      <property name="owner">
        <property-ui type="textBox"
                     label="Owner"
                     description="The owner of the defect."/>
      </property>
      <property name="defectDescription">
        <property-ui type="textAreaBox"
                     label="Defect Description"
                     description="The description of the defect."/>
      </property>
      <property name="automation" required="true">
        <property-ui type="automationPropSheetRef"
                     label="ClearQuest Server"
                     description="The ClearQuest server. This may be configured under the System tab."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/httpcore.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/httpmime.jar:lib/HttpComponents-Util.jar:lib/CommonsUtil.jar:lib/commons-logging.jar:lib/commons-codec.jar:lib/log4j.jar"/>
      <arg file="create-defect.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
  
  
  <step-type name="Resolve Issue">
    <description>Resolve a ClearQuest Defect</description>
    <properties>
      <property name="defectId" required="true">
        <property-ui type="textBox"
                     label="Defect ID"
                     description="The id of the ClearQuest defect."/>
      </property>
      <property name="resolution">
        <property-ui type="textBox"
                     label="Resolution"
                     description="The resolution which resolved the issue."/>
      </property>
      <property name="automation" required="true">
        <property-ui type="automationPropSheetRef"
                     label="ClearQuest Server"
                     description="The ClearQuest server. This may be configured under the System tab."/>
      </property>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/httpcore.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/httpmime.jar:lib/HttpComponents-Util.jar:lib/CommonsUtil.jar:lib/commons-logging.jar:lib/commons-codec.jar:lib/log4j.jar"/>
      <arg file="resolve-defect.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
  
    <!-- ==================================== -->
    <!--   AUTOMATION                         -->
    <!-- ==================================== -->
    <server:property-group type="Automation" name="ClearQuest Server">
      <server:property name="username">
        <server:property-ui type="textBox"
                            label="Username"
                            description="The username to connect to the ClearQuest database."/>
      </server:property>
      <server:property name="password">
        <server:property-ui type="secureBox"
                            label="Password"
                            description="The user password."/>
      </server:property>
      <server:property name="passwordScript">
        <server:property-ui type="textBox"
                            label="Scripted Password"
                            description="If you would prefer to resolve the password with a script,
                            enter it here."/>
      </server:property>
      <server:property name="dbName" required="true">
        <server:property-ui type="textBox"
                            label="Database Name"
                            description="The name of the ClearQuest database."/>
      </server:property>
      <server:property name="schema" required="true">
        <server:property-ui type="textBox"
                            label="Database Schema"
                            description="The ClearQuest database schema name."/>
      </server:property>
      <server:property name="commandPath" required="true">
        <server:property-ui type="textBox"
                            label="CQperl.exe path"
                            description="The filepath designating 'CQperl.exe'."/>
      </server:property>
      <server:property name="issueUrl">
        <server:property-ui type="textBox"
                            label="Issue URL"
                            description="This field provides a template which may be used throughout
                            uBuild to generate links from issues directly to an issue description
                            page within your issue tracker. The value '${issueId}' will be replaced
                            in the template with the issue id of the associated issue. Please provide
                            a url template such as http://bugs.company.com/browse/${issueId}."/>
      </server:property>
      
    </server:property-group>
</plugin>
