<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed Materials - Property of IBM* and/or HCL**
- UrbanCode Deploy
- UrbanCode Build
- UrbanCode Release
- AnthillPro
- (c) Copyright IBM Corporation 2011, 2017. All Rights Reserved.
- (c) Copyright HCL Technologies Ltd. 2018. All Rights Reserved.
-
- U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by
- GSA ADP Schedule Contract with IBM Corp.
-
- * Trademark of International Business Machines
- ** Trademark of HCL Technologies Limited
-->
<plugin xmlns="http://www.urbancode.com/PluginXMLSchema_v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <header>
    <identifier id="com.urbancode.air.plugin.uDeployVersion" name="UrbanCode Deploy Versions" version="76"/>
    <description>
        Plugin for editing Component Versions in UrbanCode Deploy.
      </description>
    <tag>UrbanCode Deploy/Versions</tag>
  </header>
  <step-type name="Add Status to Version">
    <description>Add a status to a Component Version</description>
    <properties>
      <property name="status">
        <property-ui type="textBox"
                     label="Status"
                     description="The status to be applied to the Component Version."/>
      </property>
      <property name="versionName">
        <property-ui type="textBox"
                     label="Version Name"
                     description="The name of the version to apply the status to."
                     hidden="true"
                     default-value="${p:version.name}"/>
      </property>
      <property name="componentName">
        <property-ui type="textBox"
                     label="Component Name"
                     description="The name of the component whose version to apply the status to."
                     hidden="true"
                     default-value="${p:component.name}"/>
      </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/uDeploy-Version.jar"/>
      <arg file="add.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Remove Status from Version">
    <description>Remove a status from a Component Version</description>
    <properties>
      <property name="status">
        <property-ui type="textBox"
                     label="Status"
                     description="The status to be removed from the Component Version."/>
      </property>
      <property name="versionName">
        <property-ui type="textBox"
                     label="Version Name"
                     description="The name of the version to remove the status from."
                     hidden="true"
                     default-value="${p:version.name}"/>
      </property>
      <property name="componentName">
        <property-ui type="textBox"
                     label="Component Name"
                     description="The name of the component whose version to remove the status from."
                     hidden="true"
                     default-value="${p:component.name}"/>
      </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/uDeploy-Version.jar"/>
      <arg file="remove.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Create Version">
    <description>Create a Component Version and optionally upload files into it.</description>
    <properties>
      <property name="componentName" required="true">
        <property-ui type="textBox"
                     label="Component Name"
                     description="The name of the Component for which to create a Version."
                     default-value="${p:component.name}"/>
      </property>
      <property name="versionName" required="true">
        <property-ui type="textBox"
                     label="Version Name"
                     description="The name of the Version to create."
                     default-value="${p:version.name}"/>
      </property>
      <property name="uploadFiles" required="false">
        <property-ui type="checkBox" description="Upload files from the current working directory to the version after creation?" label="Upload Files"/>
      </property>
      <property name="includes" required="true">
        <property-ui type="textAreaBox" label="Includes" description="The patterns to match files to upload. The wildcard ** indicates every directory and the wildcard * indicates every file. So the pattern dist/**/* would retrieve the entire file tree underneath the dist directory." default-value="**/*"/>
      </property>
      <property name="excludes">
        <property-ui type="textAreaBox" label="Excludes" description="The patterns to exclude files to upload."/>
      </property>
      <property name="saveFileExecuteBits" required="false">
        <property-ui type="checkBox" label="Save File Execute Bits" description="When enabled, file execute bits are saved with the files." default-value="false"/>
      </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/uDeploy-Version.jar"/>
      <arg file="createVersion.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
  <step-type name="Get Version Properties">
    <description>Get the properties of a specific Version in the output properties of this step.</description>
    <properties>
      <property name="version" required="true">
        <property-ui type="textBox" label="Version" description="The name or ID of the version with desired properties. If specifying a version name, you must specify a component."/>
      </property>
      <property name="component" required="false">
        <property-ui type="textBox" label="Component" description="(Optional) The name or ID of the component whose version has desired properties."/>
      </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/uDeploy-Version.jar"/>
      <arg file="getVersionProperties.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

    <step-type name="Add Version Link">
    <description>Creates or removes a link on a component version which can direct users to supplementary information related to the execution.</description>
    <properties>
      <property name="versionName" required="true">
        <property-ui type="textBox"
                     label="Version Name/ID"
                     description="Name or ID of version where link will be assigned. Ignored if 'Component's latest version' is selected"
                     default-value="${p:version.id}"/>
      </property>
      <property name="componentName">
        <property-ui type="textBox"
                     label="Component Name"
                     description="Name or ID of the version's component. Ignored if 'Version ID' is selected."
                     default-value="${p:component.name}"/>
      </property>
      <property name="linkTitle" required="true">
        <property-ui type="textBox"
                     label="Link Title"
                     description="The link text which the user can click on."/>
      </property>
      <property name="linkURL" required="true">
        <property-ui type="textBox"
                     label="URL"
                     description="The website the user will be directed to when the link title is clicked."/>
      </property>
      <property name="isPriority">
        <property-ui type="checkBox"
                     label="Make Priority"
                     description="When checked, prioritize the link by placing it in the page header for quicker access." />
      </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/uDeploy-Version.jar"/>
      <arg file="addVersionLink.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Get Version Status Information">
    <description>
        Retrieve the status information for a Version and sets the output properties:
        versionLatestStatus, versionStatuses, and versionStatusIds.
        The versionStatuses and versionStatusIds. properties will contain a comman-separated-values list of
        all statuses on the Version.
        Optionally, print a message and fail this step unless a required Status is present on the Version.
    </description>
    <properties>
      <property name="versionName" required="true">
        <property-ui type="textBox"
                     label="Version Name/ID"
                     description="Name or ID of the version to get Status information."
                     default-value="${p:version.id}"/>
      </property>
      <property name="componentName">
        <property-ui type="textBox"
                     label="Component Name"
                     description="Name or ID of the version's component. Required if Version is provided by name."
                     default-value="${p:component.name}"/>
      </property>

      <property name="requiredStatus">
        <property-ui type="textBox"
                     label="Required Status Name/ID"
                     description="Fail this step unless the given Status Name/ID is present on the Version"
                     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="${PLUGIN_HOME}/javawrapper.sh">
      <arg value="-cp"/>
      <arg path="classes:lib/uDeploy-Version.jar"/>
      <arg value="com.urbancode.air.plugin.udeployversion.GetVersionStatusInfoStep"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
</plugin>
