<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed Materials - Property of IBM Corp.
- IBM UrbanCode Build
- (c) Copyright IBM Corporation 2012, 2014. All Rights Reserved.
-
- U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by
- GSA ADP Schedule Contract with IBM Corp.
-->
<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.QualityCenter" name="HP Quality Center" version="8"/>
    <description>
       The HP Quality Center Plugin automates the creation and deletion of issues in QC. The plugin can also run test sets and publish the test reports.
    </description>
    <tag>Quality/Issue Tracking/HP Quality Center</tag>
    <server:plugin-type>Automation</server:plugin-type>
  </header>
  <!-- ======================== -->
  <!--   CREATE ISSUE           -->
  <!-- ======================== -->
  <step-type name="Create Issue">
    <description>Create a new defect in HP Quality Center.</description>
    <properties>
      <property name="qcdomain" required="true">
        <server:property-ui type="textBox"
                            label="Domain"
                            description="The Domain in Quality Center the defect is in."/>
      </property>
      <property name="qcproject" required="true">
        <server:property-ui type="textBox"
                            label="Project"
                            description="The Project in Quality Center the defect is in."/>
      </property>
      <property name="qcprojectkey" required="true">
        <server:property-ui type="textBox"
                            label="Project Key"
                            description="The Project Key in Quality Center."/>
      </property>
      <property name="assignee" required="true">
        <server:property-ui type="textBox"
                            label="Assignee"
                            description="The assignee for the new defect."/>
      </property>
      <property name="summary" required="true">
        <server:property-ui type="textBox"
                            label="Summary"
                            description="A summary for the new defect. Default max length is 255."/>
      </property>
      <property name="detectedby">
        <server:property-ui type="textBox"
                            label="Detected By"
                            description="Who detected the defect."/>
      </property>
      <property name="priority">
        <server:property-ui type="textBox"
                            label="Priority"
                            description="The priority of the new defect. Default values are ( 1-Low, 2-Medium, 3-High, 4-Very High, 5-Urgent )"/>
      </property>
      <property name="severity" required="true">
        <server:property-ui type="textBox"
                            label="Severity"
                            description="The severity of the new defect. Default values are ( 1-Low, 2-Medium, 3-High, 4-Very High, 5-Urgent )"/>
      </property>
      <property name="status">
        <server:property-ui type="textBox"
                            label="Status"
                            default-value="New"
                            description="The status of the new defect. Default values are ( Closed, Fixed, New, Open, Rejected, Reopen )"/>
      </property>
      <property name="props">
        <server:property-ui type="textAreaBox"
                            label="Additional Fields"
                            description="Additional defect fields to be added. Enter one per line, as name=value pairs. This uses Java's java.util.Properties format."/>
      </property>
      <property name="automation" required="true">
        <server:property-ui type="automationPropSheetRef"
                            label="Quality Center Configuration"/>
      </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"/>
      <arg file="qc_create.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <!-- ======================== -->
  <!--   UPDATE ISSUES          -->
  <!-- ======================== -->
  <step-type name="Update Issues">
    <description>Update one or more defects in HP Quality Center.</description>
    <properties>
      <property name="qcdomain" required="true">
        <server:property-ui type="textBox"
                            label="Domain"
                            description="The Domain in Quality Center the defect is in."/>
      </property>
      <property name="qcproject" required="true">
        <server:property-ui type="textBox"
                            label="Project"
                            description="The Project in Quality Center the defect is in."/>
      </property>
      <property name="capturemode" required="true">
        <server:property-ui type="selectBox"
                            label="Capture Mode"
                            description="Choose how to locate defects to update. Select List to list the defect Ids as comma-separated values below. Eg. '4, 24, 13' Select Regex to specify a regular expressions used to parse the build life's change logs for defects. Eg. 'QC-([0-9]+)'"/>
        <server:value label="Regex">regex</server:value>
        <server:value label="List">list</server:value>
      </property>
      <property name="bugpattern" required="true">
        <server:property-ui type="textBox"
                            label="Defect Ids"
                            description="Comma separated list of defect ids to update."/>
      </property>
      <property name="assignee">
        <server:property-ui type="textBox"
                            label="Assignee"
                            description="The new assignee for the defect or blank to not change."/>
      </property>
      <property name="summary">
        <server:property-ui type="textBox"
                            label="Summary"
                            description="A new summary for the defect or blank to not change. Default max length is 255."/>
      </property>
      <property name="priority">
        <server:property-ui type="textBox"
                            label="Priority"
                            description="The new priority of the defect or blank to not change. Default values are ( 1-Low, 2-Medium, 3-High, 4-Very High, 5-Urgent )"/>
      </property>
      <property name="severity">
        <server:property-ui type="textBox"
                            label="Severity"
                            description="The new severity of the defect or blank to not change. Default values are ( 1-Low, 2-Medium, 3-High, 4-Very High, 5-Urgent )"/>
      </property>
      <property name="status">
        <server:property-ui type="textBox"
                            label="Status"
                            description="The new status of the defect or blank to not change. Default values are ( Closed, Fixed, New, Open, Rejected, Reopen )"/>
      </property>
      <property name="failmode" required="true">
        <server:property-ui type="selectBox"
                            label="Fail Mode"
                            description="What should be done when a defect to be updated is not found in Quality Center. Fail-fast: fail the step immediately if a defect is not found. Fail: fail the step after attempting to update all defects. Warn: log a warning when a defect is not found."/>
        <server:value label="Fail-fast">fast</server:value>
        <server:value label="Fail">slow</server:value>
        <server:value label="Warn">warn</server:value>
      </property>
      <property name="props">
        <server:property-ui type="textAreaBox"
                            label="Additional Fields"
                            description="Any other additional defect fields to update. These should be one per line, as name=value pairs. Adheres specifically to the java.util.Properties format."/>
      </property>
      <property name="comment">
        <server:property-ui type="textAreaBox"
                            label="Comment"
                            description="Optionally add a comment with this update." />
      </property>
      <property name="automation" required="true">
        <server:property-ui type="automationPropSheetRef"
                            label="Quality Center Configuration"/>
      </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/CommonsFileUtils.jar: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="qc_update.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <!-- ======================== -->
  <!--   ADD COMMENTS           -->
  <!-- ======================== -->
  <step-type name="Add Comments">
    <description>Add comments to a defect in HP Quality Center.</description>
    <properties>
     <property name="qcdomain" required="true">
        <server:property-ui type="textBox"
                            label="Domain"
                            description="The Domain in Quality Center the defect is in."/>
      </property>
      <property name="qcproject" required="true">
        <server:property-ui type="textBox"
                            label="Project"
                            description="The Project in Quality Center the defect is in."/>
      </property>
      <property name="bugpattern" required="true">
        <server:property-ui type="textBox"
                            label="Defect Ids"
                            description="A regular expression representing a list of bug Ids. Ex: 14[0-9] to match issues 140 through 149."/>
      </property>
      <property name="additionalcomments">
        <server:property-ui type="textAreaBox"
                            label="Additional Comments"
                            description="Any info you wish to be added to the Quality Center comment in addition to the commit comment."/>
      </property>
      <property name="failmode" required="true">
        <server:property-ui type="selectBox"
                            label="Fail Mode"
                            description="What should be done when a defect to be commented on is not found in Quality Center. Fail-fast: fail the step immediately if a defect is not found. Fail: fail the step after attempting to comment on all defects. Warn: log a warning when a defect is not found."/>
        <server:value label="Fail-fast">fast</server:value>
        <server:value label="Fail">slow</server:value>
        <server:value label="Warn">warn</server:value>
      </property>
      <property name="automation" required="true">
        <server:property-ui type="automationPropSheetRef"
                            label="Quality Center Configuration"/>
      </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/CommonsFileUtils.jar: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="qc_add_comments.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <!-- ======================== -->
  <!--   PUBLISH ISSUE REPORT   -->
  <!-- ======================== -->
  <step-type name="Publish Issue Report">
    <description>Create a report of Quality Center defects from the current changelog.</description>
    <properties>
      <property name="qcdomain" required="true">
        <server:property-ui type="textBox"
                            label="Domain"
                            description="The Domain in Quality Center the defect is in."/>
      </property>
      <property name="qcproject" required="true">
        <server:property-ui type="textBox"
                            label="Project"
                            description="The Project in Quality Center the defect is in."/>
      </property>
      <property name="bugpattern" required="true">
        <server:property-ui type="textBox"
                            label="Defect Id Pattern"
                            description="The regex used to match changes to defects. The default value, QC-([0-9]+) is a regex that parses the change log and applies the attributes of the step to matching defects. For example, if QC-52 was located in the comment of a change, this step would act on defect 52 in the Quality Center database." />
      </property>
      <property name="failmode" required="true">
        <server:property-ui type="selectBox"
                            label="Fail Mode"
                            description="What should be done when a defect to be reported is not found in Quality Center. Fail-fast: fail the step immediately if a defect is not found. Fail: fail the step after publishing the report of found defects. Warn: log a warning when a defect is not found."/>
        <server:value label="Fail-fast">fast</server:value>
        <server:value label="Fail">slow</server:value>
        <server:value label="Warn">warn</server:value>
      </property>
      <property name="automation" required="true">
        <server:property-ui type="automationPropSheetRef"
                            label="Quality Center Configuration"/>
      </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/CommonsFileUtils.jar: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:lib/jsoup.jar"/>
      <arg file="qc_publish_bug_report.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <!-- ======================== -->
  <!--   RUN TEST SET           -->
  <!-- ======================== -->
  <step-type name="Run Test Set">
    <description>Run a Test Set using HP Quality Center.</description>
    <properties>
      <property name="qcdomain" required="true">
        <server:property-ui type="textBox"
                            label="Domain"
                            description="The Domain in Quality Center the defect is in."/>
      </property>
      <property name="qcproject" required="true">
        <server:property-ui type="textBox"
                            label="Project"
                            description="The Project in Quality Center the defect is in."/>
      </property>
      <property name="folder" required="true">
        <server:property-ui type="textBox"
                            label="Folder"
                            description="The folder in Quality Center the test set resides in. This usually starts with &quot;Root&quot;."/>
      </property>
      <property name="testSetName" required="true">
        <server:property-ui type="textBox"
                            label="Test Set"
                            description="The test set to run."/>
      </property>
      <property name="threshold" required="true">
        <server:property-ui type="textBox"
                            label="Success Threshold"
                            description="A numeric value representing the percentage of tests that must succeed for the
                            step to be considered successful. If the test pass rate is below this value, the step will fail.
                            Ex: For the success threshold to be 90%, enter 90."
                            default-value="100"/>
      </property>
      <property name="remotehost" required="false">
        <server:property-ui type="textBox"
                            label="Remote Host"
                            description="The host to run the tests on. If left blank, the tests will run locally."/>
      </property>
      <property name="automation" required="true">
        <server:property-ui type="automationPropSheetRef"
                            label="Quality Center Configuration"/>
      </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"/>
      <arg file="qc_run_test_set.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <!-- ======================== -->
  <!--   PUBLISH TEST SET REPORT-->
  <!-- ======================== -->
  <step-type name="Publish Test Set Report">
    <description>Publish a HP Quality Center Test Set Report.</description>
    <properties>
      <property name="qcdomain" required="true">
        <server:property-ui type="textBox"
                            label="Domain"
                            description="The Domain in Quality Center the defect is in."/>
      </property>
      <property name="qcproject" required="true">
        <server:property-ui type="textBox"
                            label="Project"
                            description="The Project in Quality Center the defect is in."/>
      </property>
      <property name="folder" required="true">
        <server:property-ui type="textBox"
                            label="Folder"
                            description="The folder in Quality Center the test set resides in. This usually starts with &quot;Root&quot;."/>
      </property>
      <property name="testSetName" required="true">
        <server:property-ui type="textBox"
                            label="Test Set"
                            description="The test set results to publish."/>
      </property>
      <property name="reportName" required="true">
        <server:property-ui type="textBox"
                            label="Report Name"
                            description="The name of the report published to the Anthill build life."/>
      </property>
      <property name="automation" required="true">
        <server:property-ui type="automationPropSheetRef"
                            label="Quality Center Configuration"/>
      </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/CommonsFileUtils.jar: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="qc_publish_test_report.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Verify Issues Field">
    <description>
      Verify that all of the Issues associated with the current Build Life have a given field values
    </description>
    <properties>
      <property name="qcdomain" required="true">
        <server:property-ui type="textBox"
                            label="Domain"
                            description="The Domain in Quality Center the defect is in."/>
      </property>
      <property name="qcproject" required="true">
        <server:property-ui type="textBox"
                            label="Project"
                            description="The Project in Quality Center the defect is in."/>
      </property>
      <property name="fieldName" required="true">
        <server:property-ui type="textBox"
                            label="Field Name"
                            description="The field name. Ex: BG_STATUS"/>
      </property>
      <property name="fieldValue" required="true">
        <server:property-ui type="textBox"
                            label="Value"
                            description="A comma-separated list of expected values. Ex: Fixed,Closed"/>
      </property>
      <property name="useHistory">
        <server:property-ui type="checkBox"
                            label="Check History"
                            description="Check the historical values in addition to the current value"/>
      </property>
      <property name="requireAllValues">
        <server:property-ui type="checkBox"
                            label="Require All"
                            description="If all values must be present. Only valid if Check History is also selected"/>
      </property>
      <property name="automation" required="true">
        <server:property-ui type="automationPropSheetRef"
                            label="Quality Center Configuration"/>
      </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/CommonsFileUtils.jar: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="qc_verify_issues.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

    <!-- ==================================== -->
    <!--  AUTOMATION                          -->
    <!-- ==================================== -->
    <server:property-group type="Automation" name="Automation">
      <server:description>
          This represents the connectivity settings for a HP Quality Center. In order for this plugin
          to work with HP ALM 11 and later, you must open the web UI of HP ALM from the agent machine, click on their
          'Add-ins Page' link and install the 'HP ALM Connectivity' add-in.
      </server:description>
      <server:property name="serverUrl" required="true">
        <server:property-ui type="textBox"
                            label="Server URL"
                            description="The base URL of the Quality Center instance. It usually ends with '/qcbin'."/>
      </server:property>
      <server:property name="username" required="true">
        <server:property-ui type="textBox"
                            label="Username"
                            description="The username to authenticate with Quality Center."/>
      </server:property>
      <server:property name="password">
        <server:property-ui type="secureBox"
                            label="Password"
                            description="The password to authenticate with Quality Center."/>
      </server:property>
      <server:property name="passwordscript">
        <server:property-ui type="textAreaBox"
                            label="Password Script"
                            description="If a property or script should be used to set the password, leave password blank and put the property or script here."/>
      </server:property>
    </server:property-group>
</plugin>
