<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed Materials - Property of IBM Corp.
- IBM UrbanCode Build
- IBM UrbanCode Deploy
- IBM UrbanCode Release
- IBM AnthillPro
- (c) Copyright IBM Corporation 2002, 2016. 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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:server="http://www.urbancode.com/PluginServerXMLSchema_v1">
  <header>
    <identifier id="com.urbancode.air.plugin.RTCWorkItems" name="RTC Work Items" version="8"/>
    <description>
The RTC Work Items plugin provides steps for the build to comment and change the status of work items found in RTC
      </description>
    <tag>Issue Tracking/RTC WorkItems</tag>
    <server:required-server-version>6.0.1.0</server:required-server-version>
  </header>
  <step-type name="Add Work Item Comments">
    <description>Add Comments to an RTC Work Item</description>
    <properties>
      <property name="url" required="true">
        <property-ui type="textBox" label="RTC Server URL" description="The URL of the RTC server like https://myserver:9443/jazz"/>
      </property>
      <property name="username" required="true">
        <property-ui type="textBox" label="User Name" description="The user name to be used to connect to the RTC server."/>
      </property>
      <property name="password" required="true">
        <property-ui type="secureBox" label="Password" description="The password to be used to connect to the RTC server."/>
      </property>
      <property name="projectName" required="true">
        <property-ui type="textBox" label="Project Name" description="The RTC project name containing the work item to add comments to."/>
      </property>
      <property name="workItemId" required="true">
        <property-ui type="textBox" label="Work Item ID" description="The ID number of the RTC work item to add comments to." default-value="${p:workItemId}"/>
      </property>
      <property name="comment" required="true">
       <property-ui type="textAreaBox" label="Comment" description="The comment to add to the RTC Work Item."/>
      </property>
      <property name="addCommentUrl">
        <property-ui type="checkBox" label="Add URL to Comment" description="Check to append the URL of the process request to the comment to be posted."/>
      </property>
      <property name="requestId">
        <property-ui type="textBox" label="Request Id" hidden="true" default-value="${p?:request.id}"/>
      </property>
      <property name="appProcId">
        <property-ui type="textBox" label="Application Process Id" hidden="true" default-value="${p?:applicationProcess.id}"/>
      </property>
      <property name="compProcId">
        <property-ui type="textBox" label="Component Process Id" hidden="true" default-value="${p?:componentProcess.id}"/>
      </property>
      <property name="procId">
        <property-ui type="textBox" label="Process Id" hidden="true" default-value="${p?:process.id}"/>
      </property>
      <property name="serverUrl">
        <property-ui type="textBox" label="Server Url" hidden="true" default-value="${p?:server.url}"/>
      </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/CommonsUtil.jar;lib/log4j.jar;lib/commons-io.jar;lib/HttpComponents-Util.jar;lib/httpclient.jar;lib/httpcore.jar:lib/securedata.jar:lib/jettison-1.1.jar:lib/commons-codec.jar"/>
      <arg file="add_comments.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

 <step-type name="Change Work Item Status">
    <description>Change the status of an RTC Work Item</description>
    <properties>
      <property name="url" required="true">
        <property-ui type="textBox" label="RTC Server URL" description="The URL of the RTC server like https://myserver:9443/jazz"/>
      </property>
      <property name="username" required="true">
        <property-ui type="textBox" label="User Name" description="The user name to be used to connect to the RTC server."/>
      </property>
      <property name="password" required="true">
        <property-ui type="secureBox" label="Password" description="The password to be used to connect to the RTC server."/>
      </property>
      <property name="projectName" required="true">
        <property-ui type="textBox" label="Project Name" description="The RTC project name containing the work item to add comments to."/>
      </property>
      <property name="workItemId" required="true">
        <property-ui type="textBox" label="Work Item ID" description="The ID number of the RTC work item to add comments to." default-value="${p:workItemId}"/>
      </property>
      <property name="action">
        <property-ui type="textBox" label="Action" description="The action to be performed on the work item."/>
      </property>
      <property name="newState">
        <property-ui type="textBox" label="New State" description="The new state for the work item. Will not be used if action is given."/>
      </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/CommonsUtil.jar;lib/log4j.jar;lib/commons-io.jar;lib/HttpComponents-Util.jar;lib/httpclient.jar;lib/httpcore.jar:lib/securedata.jar:lib/jettison-1.1.jar:lib/commons-codec.jar"/>
      <arg file="change_defect_status.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
  <step-type name="Check Work Item Status">
     <description>Check a work item for a specific status.</description>
     <properties>
       <property name="url" required="true">
         <property-ui type="textBox" label="RTC Server URL"
                      description="The URL of the Rational Team Concert server. For example: https://myserver:9443/jazz"/>
       </property>
       <property name="username" required="true">
         <property-ui type="textBox" label="User Name"
                      description="The user name to use to connect to the Rational Team Concert server."/>
       </property>
       <property name="password" required="true">
         <property-ui type="secureBox" label="Password"
                      description="The password to use to connect to the Rational Team Concert server."/>
       </property>
       <property name="projectName" required="true">
         <property-ui type="textBox" label="Project Name"
                      description="The name of the Rational Team Concert project that contains the work item to check."/>
       </property>
       <property name="workItemId" required="true">
         <property-ui type="textBox" label="Work Item ID"
                      description="The ID number of the Rational Team Concert work item to check."
                      default-value="${p:workItemId}"/>
       </property>
       <property name="status">
         <property-ui type="textBox" label="Status"
                      description="A status to validate against. If the work item status doesn't match this status, the step
                                   fails. If the statuses match, the step succeeds. Leave blank to retrieve the work item status
                                   as an output property."/>
       </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/CommonsUtil.jar;lib/log4j.jar;lib/commons-io.jar;lib/HttpComponents-Util.jar;lib/httpclient.jar;lib/httpcore.jar:lib/securedata.jar:lib/jettison-1.1.jar:lib/commons-codec.jar"/>
       <arg file="check_status.groovy"/>
       <arg file="${PLUGIN_INPUT_PROPS}"/>
       <arg file="${PLUGIN_OUTPUT_PROPS}"/>
     </command>
   </step-type>
   <step-type name="Create Work Item">
    <description>Create an RTC Work Item</description>
    <properties>
      <property name="workItemType" required="true">
        <property-ui
            type="textBox"
            label="Work Item Type"
            default-value="Defect"
            description="The type of work item you want to create, for example Defect, Task, Story, Risk, etc.
              This field is case sensitive."/>
      </property>
      <property name="workItemSummary" required="true">
        <property-ui
            type="textBox"
            label="Work Item Summary"
            description="The summary/title for the new work item."/>
      </property>
      <property name="workItemDescription">
        <property-ui
            type="textAreaBox"
            label="Work Item Description"
            description="The description for the new work item."/>
      </property>
      <property name="workItemTags">
        <property-ui
            type="textAreaBox"
            label="Work Item Tags"
            description="List of tags to assign the new work item. Separate each tag by a new line or comma."/>
      </property>
      <property name="filedAgainst">
        <property-ui
            type="textBox"
            label="Filed Against"
            description="The category this work item should be filed against. By default this is required and Unassigned
              is not an acceptable value. This field is case sensitive."/>
      </property>
      <property name="additionalAttributes">
        <property-ui
            type="textAreaBox"
            label="Additional Work Item attributes"
            description="Enter a new-line-separated name=value pairs for any additional or custom attributes you want to
              populate in the new work item. The name is the ID of the attribute and value is the value. This field
              currently only supports rtc_cm type text based value attributes as described here
              https://jazz.net/wiki/bin/view/Main/ResourceOrientedWorkItemAPIv2#Attributes and non text values are by
              ID reference."/>
      </property>
      <property name="url" required="true">
        <property-ui
            type="textBox"
            label="RTC Server URL"
            description="The URL of the RTC server like https://myserver:9443/jazz"/>
      </property>
      <property name="username" required="true">
        <property-ui
            type="textBox"
            label="User Name"
            description="The user name to be used to connect to the RTC server."/>
      </property>
      <property name="password" required="true">
        <property-ui
            type="secureBox"
            label="Password"
            description="The password to be used to connect to the RTC server."/>
      </property>
      <property name="projectName" required="true">
        <property-ui
            type="textBox"
            label="Project Name"
            description="The RTC project name where the work item will be created."/>
      </property>
      <property name="comment">
        <property-ui
            type="textAreaBox"
            label="Comment"
            description="If you want to add a comment to the new work item enter it here. Check below if you want to add
              a link back to UCD execution in the comment."/>
      </property>
      <property name="addCommentUrl">
        <property-ui
            type="checkBox"
            label="Add URL to Comment"
            description="Check to append the URL of the process request to the comment to be posted."/>
      </property>
      <property name="requestId">
        <property-ui
            type="textBox"
            label="Request Id"
            hidden="true"
            default-value="${p?:request.id}"/>
      </property>
      <property name="appProcId">
        <property-ui
            type="textBox"
            label="Application Process Id"
            hidden="true"
            default-value="${p?:applicationProcess.id}"/>
      </property>
      <property name="compProcId">
        <property-ui
            type="textBox"
            label="Component Process Id"
            hidden="true"
            default-value="${p?:componentProcess.id}"/>
      </property>
      <property name="procId">
        <property-ui
            type="textBox"
            label="Process Id"
            hidden="true"
            default-value="${p?:process.id}"/>
      </property>
      <property name="serverUrl">
        <property-ui
            type="textBox"
            label="Server Url"
            hidden="true"
            default-value="${p?:server.url}"/>
      </property>
      <property name="debug">
        <property-ui
            type="checkBox"
            label="Debug Work Item XML"
            hidden="true"
            default-value=""/>
      </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/CommonsUtil.jar;lib/log4j.jar;lib/commons-io.jar;lib/HttpComponents-Util.jar;lib/httpclient.jar;lib/httpcore.jar:lib/securedata.jar:lib/jettison-1.1.jar:lib/commons-codec.jar"/>
      <arg file="create_workitem.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

</plugin>
