<?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.
-->
<!--
  classpath "classes:lib/udclient.jar:lib/ibm-ucb-codestation-client-all-without-log4j.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/jsr311-api-1.1.1.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/commons-web.jar:lib/commons-codec.jar:lib/commons-lang3.jar"
-->
<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.uDeploy" name="IBM UrbanCode Deploy" version="32"/>
    <description>This plugin provides a component version creation in IBM UrbanCode Deploy and the option to upload files to it.</description>
    <tag>Deploy/Tools/IBM UrbanCode Deploy</tag>
    <server:plugin-type>Automation</server:plugin-type>
  </header>

  <step-type name="Create Component Version">
    <description>Create a component version in IBM UrbanCode Deploy and optionally upload files to it.</description>
      <properties>
        <property name="componentName" required="true">
            <server:property-ui type="textBox"
                                label="Component Name"
                                description="The name of the component to create the version on in IBM UrbanCode Deploy."
                                default-value="${p:project/name}"/>
        </property>
        <property name="versionName" required="true">
            <server:property-ui type="textBox"
                                label="Version Name"
                                description="The name of the version to create in IBM UrbanCode Deploy."
                                default-value="${p:buildlife/latestStamp}"/>
        </property>
        <property name="versionDesc">
            <server:property-ui type="textAreaBox"
                                label="Description"
                                description="The description of the version to create in IBM UrbanCode Deploy."/>
        </property>
        <property name="status">
          <server:property-ui type="textBox"
                              label="Status Name"
                              description="The name of the status in IBM UrbanCode Deploy or IBM UrbanCode Build that you want to add to the version" />
        </property>
        <property name="publishFiles">
            <server:property-ui type="checkBox"
                                label="Upload Files"
                                description="Check to upload files to the created version."/>
        </property>
        <property name="artifactsBaseDir">
          <server:property-ui type="textBox"
                              label="Artifacts Base Directory"
                              description="The directory relative to the working directory for the step in which the artifacts are located. This value is only used if Upload Files is checked."/>
        </property>
        <property name="includes">
          <server:property-ui type="textAreaBox"
                              label="Include Patterns"
                              description="Patterns for including files to be uploaded to IBM UrbanCode Deploy. Patterns can include ?, *, or **." />
        </property>
        <property name="excludes">
          <server:property-ui type="textAreaBox"
                              label="Exclude Patterns"
                              description="Patterns for excluded files from an upload to IBM UrbanCode Deploy. Patterns can include ?, *, or **." />
        </property>
        <property name="propertiesTextArea">
          <server:property-ui type="textAreaBox"
                              label="Properties"
                              description="The properties to set on the component version. Enter each property on a new line. Separate the property name and value with '='." />
        </property>
        <property name="createVersionLink">
          <server:property-ui type="checkBox"
                              label="Create Version Link"
                              description="Create a link on the version that links back to the build life."
                              default-value="true"/>
        </property>
        <property name="linkName">
          <server:property-ui type="textBox"
                              label="Link Name"
                              description="If creating a version link, the name of the link to create on the version"
                              default-value="IBM UrbanCode Build"/>
        </property>
        <property name="linkUrl">
          <server:property-ui type="textBox"
                              label="Link URL"
                              description="The URL of the link being created on the version"
                              default-value="${p:buildlife/url}"
                              hidden="true"/>
        </property>
        <property name="testPercentage">
          <server:property-ui type="checkBox"
                              label="Send Test Success Percentage"
                              description="Add test success percentage as a property."/>
        </property>
        <property name="codeAnalytics">
          <server:property-ui type="checkBox"
                              label="Send Code Analytics"
                              description="Add code analytics as a property."/>
        </property>
        <property name="codeCoverage">
          <server:property-ui type="checkBox"
                              label="Send Code Coverage"
                              description="Add code coverage percentage as a property."/>
        </property>
        <property name="sourceChange">
          <server:property-ui type="checkBox"
                              label="Send Source Changes"
                              description="Add source changes as a property."/>
        </property>
        <property name="workItem">
          <server:property-ui type="checkBox"
                              label="Send Work Items"
                              description="Add work items as a property."/>
        </property>
        <property name="automation" required="true">
            <server:property-ui type="automationPropSheetRef"
                                label="IBM UrbanCode Deploy Server"/>
        </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/udclient.jar:lib/ibm-ucb-codestation-client-all-without-log4j.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/jsr311-api-1.1.1.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/commons-web.jar:lib/commons-codec.jar:lib/commons-lang3.jar"/>
      <arg file="CreateVersion.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Upload Artifacts To Version">
    <description>Upload artifacts to an existing component version in IBM UrbanCode Deploy</description>
      <properties>
        <property name="componentName" required="true">
            <server:property-ui type="textBox"
                                label="Component Name"
                                description="The name of the component to create the version on in IBM UrbanCode Deploy."
                                default-value="${p:project/name}"/>
        </property>
        <property name="versionName" required="true">
            <server:property-ui type="textBox"
                                label="Version Name"
                                description="The name of the version to create in IBM UrbanCode Deploy."
                                default-value="${p:buildlife/latestStamp}"/>
        </property>
        <property name="versionDesc">
          <server:property-ui type="textAreaBox"
                              label="Description"
                              description="The description of the version if it needs to be created in IBM UrbanCode Deploy."/>
        </property>
        <property name="includes">
          <server:property-ui type="textAreaBox"
                              label="Include Patterns"
                              description="Patterns for including files to be uploaded to IBM UrbanCode Deploy. Patterns can include ?, *, or **." />
        </property>
        <property name="excludes">
          <server:property-ui type="textAreaBox"
                              label="Exclude Patterns"
                              description="Patterns for excluded files from an upload to IBM UrbanCode Deploy. Patterns can include ?, *, or **." />
        </property>
        <property name="automation" required="true">
            <server:property-ui type="automationPropSheetRef"
                                label="IBM UrbanCode Deploy Server"/>
        </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/udclient.jar:lib/ibm-ucb-codestation-client-all-without-log4j.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/jsr311-api-1.1.1.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/commons-web.jar:lib/commons-codec.jar:lib/commons-lang3.jar"/>
      <arg file="UploadArtifactsToVersion.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Set Component Version Properties">
    <description>Set properties on an existing component version.</description>
      <properties>
        <property name="componentName" required="true">
            <server:property-ui type="textBox"
                                label="Component Name"
                                description="The name of the component in IBM UrbanCode Deploy."
                                default-value="${p:project/name}"/>
        </property>
        <property name="versionName" required="true">
            <server:property-ui type="textBox"
                                label="Version Name"
                                description="The name of the version in IBM UrbanCode Deploy."
                                default-value="${p:buildlife/latestStamp}"/>
        </property>
        <property name="propertiesTextArea">
          <server:property-ui type="textAreaBox"
                              label="Properties"
                              description="The properties to set on the component version. Enter each property on a new line. Separate the property name and value with '='." />
        </property>
        <property name="testPercentage">
          <server:property-ui type="checkBox"
                              label="Send Test Success Percentage"
                              description="Add test success percentage as a property."/>
        </property>
        <property name="codeAnalytics">
          <server:property-ui type="checkBox"
                              label="Send Code Analytics"
                              description="Add code analytics as a property."/>
        </property>
        <property name="codeCoverage">
          <server:property-ui type="checkBox"
                              label="Send Code Coverage"
                              description="Add code coverage percentage as a property."/>
        </property>
        <property name="sourceChange">
          <server:property-ui type="checkBox"
                              label="Send Source Changes"
                              description="Add source changes as a property."/>
        </property>
        <property name="workItem">
          <server:property-ui type="checkBox"
                              label="Send Work Items"
                              description="Add work items as a property."/>
        </property>
        <property name="automation" required="true">
            <server:property-ui type="automationPropSheetRef"
                                label="IBM UrbanCode Deploy Server"/>
        </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/udclient.jar:lib/ibm-ucb-codestation-client-all-without-log4j.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/jsr311-api-1.1.1.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/commons-web.jar:lib/commons-codec.jar:lib/commons-lang3.jar"/>
      <arg file="SetVersionProperties.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Add Component Version Status">
    <description>Add a status to an existing component version.</description>
      <properties>
        <property name="componentName" required="true">
            <server:property-ui type="textBox"
                                label="Component Name"
                                description="The name of the component in IBM UrbanCode Deploy."
                                default-value="${p:project/name}"/>
        </property>
        <property name="versionName" required="true">
            <server:property-ui type="textBox"
                                label="Version Name"
                                description="The name of the version in IBM UrbanCode Deploy."
                                default-value="${p:buildlife/latestStamp}"/>
        </property>
        <property name="status" required="true">
          <server:property-ui type="textBox"
                              label="Status Name"
                              description="The name of the status in IBM UrbanCode Deploy or IBM UrbanCode Build that you want to add to the version" />
        </property>
        <property name="automation" required="true">
            <server:property-ui type="automationPropSheetRef"
                                label="IBM UrbanCode Deploy Server"/>
        </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/udclient.jar:lib/ibm-ucb-codestation-client-all-without-log4j.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/jsr311-api-1.1.1.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/commons-web.jar:lib/commons-codec.jar:lib/commons-lang3.jar"/>
      <arg file="AddVersionStatus.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Deploy Component Version">
    <description>Deploy a component version in IBM UrbanCode Deploy.</description>
      <properties>
        <property name="applicationName" required="true">
            <server:property-ui type="textBox"
                                label="Application Name"
                                description="The name of the application to deploy the component with."/>
        </property>
        <property name="applicationProcess" required="true">
            <server:property-ui type="textBox"
                                label="Application Process"
                                description="The name of the application process to use when deploying the component."/>
        </property>
        <property name="environmentName" required="true">
            <server:property-ui type="textBox"
                                label="Environment Name"
                                description="The name of the application environment to deploy the component to."/>
        </property>
        <property name="componentName" required="true">
            <server:property-ui type="textBox"
                                label="Component Name"
                                description="The name of the component to deploy."
                                default-value="${p:project/name}"/>
        </property>
        <property name="versionName" required="true">
            <server:property-ui type="textBox"
                                label="Version Name"
                                description="The name of the version to deploy."
                                default-value="${p:buildlife/latestStamp}"/>
        </property>
        <property name="onlyChanged">
            <server:property-ui type="checkBox"
                                label="Deploy Only Changed Versions"
                                description="Force deployment of versions already in the inventory"/>
        </property>
        <property name="automation" required="true">
            <server:property-ui type="automationPropSheetRef"
                                label="IBM UrbanCode Deploy Server"/>
        </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/udclient.jar:lib/ibm-ucb-codestation-client-all-without-log4j.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/jsr311-api-1.1.1.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/commons-web.jar:lib/commons-codec.jar:lib/commons-lang3.jar"/>
      <arg file="Deploy.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Upload Artifact Set">
    <description>Upload an artifact set to IBM UrbanCode Deploy.</description>
      <properties>
        <property name="componentName" required="true">
            <server:property-ui type="textBox"
                                label="Component Name"
                                description="The name of the component in IBM UrbanCode Deploy."
                                default-value="${p:project/name}"/>
        </property>
        <property name="versionName" required="true">
            <server:property-ui type="textBox"
                                label="Component Version"
                                description="The name of the version on the component in IBM UrbanCode Deploy."
                                default-value="${p:buildlife/latestStamp}"/>
        </property>
        <property name="versionDesc">
          <server:property-ui type="textAreaBox"
                              label="Description"
                              description="The description of the version if it needs to be created in IBM UrbanCode Deploy."/>
        </property>
        <property name="artifactSet">
            <server:property-ui type="textBox"
                                label="Artifact Set"
                                description="The name of the artifact set to upload to IBM UrbanCode Deploy"/>
        </property>
        <property name="suppressArtifactSetDir">
            <server:property-ui type="checkBox"
                                label="Suppress Artifact Set Dir"
                                description="Check to not include a directory with the artifact set name in IBM UrbanCode Deploy."/>
        </property>
        <property name="automation" required="true">
            <server:property-ui type="automationPropSheetRef"
                                label="IBM UrbanCode Deploy Server"/>
        </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/udclient.jar:lib/ibm-ucb-codestation-client-all-without-log4j.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/jsr311-api-1.1.1.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/commons-web.jar:lib/commons-codec.jar:lib/commons-lang3.jar"/>
      <arg file="UploadArtifactSet.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Upload All Artifact Sets">
    <description>Upload all artifact sets to IBM UrbanCode Deploy.</description>
      <properties>
        <property name="componentName" required="true">
            <server:property-ui type="textBox"
                                label="Component Name"
                                description="The name of the component in IBM UrbanCode Deploy."
                                default-value="${p:project/name}"/>
        </property>
        <property name="versionName" required="true">
            <server:property-ui type="textBox"
                                label="Component Version"
                                description="The name of the version on the component in IBM UrbanCode Deploy."
                                default-value="${p:buildlife/latestStamp}"/>
        </property>
        <property name="versionDesc">
            <server:property-ui type="textAreaBox"
                                label="Description"
                                description="The description of the version if it needs to be created in IBM UrbanCode Deploy."/>
        </property>
        <property name="propertiesTextArea">
          <server:property-ui type="textAreaBox"
                              label="Properties"
                              description="The properties to set on the component version. Enter each property on a new line. Separate the property name and value with '='." />
        </property>
        <property name="testPercentage">
          <server:property-ui type="checkBox"
                              label="Send Test Success Percentage"
                              description="Add test success percentage as a property."/>
        </property>
        <property name="codeAnalytics">
          <server:property-ui type="checkBox"
                              label="Send Code Analytics"
                              description="Add code analytics as a property."/>
        </property>
        <property name="codeCoverage">
          <server:property-ui type="checkBox"
                              label="Send Code Coverage"
                              description="Add code coverage percentage as a property."/>
        </property>
        <property name="sourceChange">
          <server:property-ui type="checkBox"
                              label="Send Source Changes"
                              description="Add source changes as a property."/>
        </property>
        <property name="workItem">
          <server:property-ui type="checkBox"
                              label="Send Work Items"
                              description="Add work items as a property."/>
        </property>
        <property name="automation" required="true">
            <server:property-ui type="automationPropSheetRef"
                                label="IBM UrbanCode Deploy Server"/>
        </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/udclient.jar:lib/ibm-ucb-codestation-client-all-without-log4j.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/jsr311-api-1.1.1.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/commons-web.jar:lib/commons-codec.jar:lib/commons-lang3.jar"/>
      <arg file="UploadAllArtifactSets.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Create Version Link">
    <description>Create a link on a version that links back to the build life</description>
    <properties>
      <property name="componentName" required="true">
        <server:property-ui type="textBox"
                            label="Component Name"
                            description="The name of the component in IBM UrbanCode Deploy."
                            default-value="${p:project/name}"/>
      </property>
      <property name="versionName" required="true">
        <server:property-ui type="textBox"
                            label="Component Version"
                            description="The name of the version on the component in IBM UrbanCode Deploy."
                            default-value="${p:buildlife/latestStamp}"/>
      </property>
      <property name="linkName">
        <server:property-ui type="textBox"
                            label="Link Name"
                            description="The name of the link being created on the version"
                            default-value="IBM UrbanCode Build"/>
      </property>
      <property name="linkUrl">
        <server:property-ui type="textBox"
                            label="Link URL"
                            description="The URL of the link being created on the version"
                            default-value="${p:buildlife/url}"/>
      </property>
      <property name="automation" required="true">
        <server:property-ui type="automationPropSheetRef"
                            label="IBM UrbanCode Deploy Server"/>
      </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/udclient.jar:lib/ibm-ucb-codestation-client-all-without-log4j.jar:lib/groovy-all-1.8.8-json-backport.jar:lib/jsr311-api-1.1.1.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/commons-web.jar:lib/commons-codec.jar:lib/commons-lang3.jar"/>
      <arg file="CreateVersionLink.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <!-- ==================================== -->
  <!--  INTEGRATION                         -->
  <!-- ==================================== -->

  <server:property-group type="Automation" name="IBM UrbanCode Deploy">
    <server:property name="url" required="true">
        <server:property-ui type="textBox"
                            label="IBM UrbanCode Deploy URL"
                            description="The IBM UrbanCode Deploy server URL including protocol and port, if needed. Example: http://ibm-ucd.domain.com:8080"/>
    </server:property>
    <server:property name="user">
        <server:property-ui type="textBox"
                            label="Username"
                            description="The username to be used to connect to the IBM UrbanCode Deploy server. Leave empty if you want to use an auth token."/>
    </server:property>
    <server:property name="password">
        <server:property-ui type="secureBox"
                            label="Password"
                            description="The password to be used to connect to the IBM UrbanCode Deploy server. Leave empty if you want to use an auth token."/>
    </server:property>
    <server:property name="passScript">
        <server:property-ui type="textAreaBox"
                            label="Password Script"
                            description="If you wish to use a property for your password, leave the Password field blank and enter a property scriptlet here."/>
    </server:property>
    <server:property name="authToken">
        <server:property-ui type="secureBox"
                            label="Auth Token"
                            description="The auth token to use to authenticate with IBM UrbanCode Deploy instead of a username and password combination."/>
    </server:property>
    <server:property name="ucdVersionSelection">
        <server:property-ui type="selectBox"
                            label="Version"
                            description="The version of IBM UrbanCode Deploy."
                            default-value="6.1"/>
        <server:value label="6.0 or earlier">6.0</server:value>
        <server:value label="6.1 or later">6.1</server:value>
    </server:property>

    <!-- Artifact Repository URL Scripts -->
    <server:property name="downloadAllArtifactsUrlScript">
      <server:property-ui type="textAreaBox"
                          label="Download All Artifacts URL Script"
                          description="The script used to generate the URL to download all artifacts for the build life."
                          hidden="true">
        <server:default-value>
          <![CDATA[
            String component = ProjectLookup.current.name
            String version = BuildLifeLookup.current.latestStampValue
            return String.valueOf("$url/cli/version/downloadArtifacts?component=$component&version=$version")
          ]]>
        </server:default-value>
      </server:property-ui>
    </server:property>

    <server:property name="downloadSingleArtifactUrlScript">
      <server:property-ui type="textAreaBox"
                          label="Download Single Artifact URL Script"
                          description="The script used to generate the URL to download a single artifact for the build life."
                          hidden="true">
        <server:default-value>
          <![CDATA[
            String component = ProjectLookup.current.name
            String version = BuildLifeLookup.current.latestStampValue
            // The server is responsible for appending the artifact path
            return String.valueOf("$url/cli/version/downloadArtifacts?component=$component&version=$version&singleFilePath=")
          ]]>
        </server:default-value>
      </server:property-ui>
    </server:property>

    <server:property name="listArtifactsUrlScript">
      <server:property-ui type="textAreaBox"
                          label="List Artifacts URL Script"
                          description="The script used to generate the URL to list all artifacts for the build life."
                          hidden="true">
        <server:default-value>
          <![CDATA[
            String component = ProjectLookup.current.name
            String version = BuildLifeLookup.current.latestStampValue
            return String.valueOf("$url/cli/version/listVersionArtifacts?component=$component&version=$version")
          ]]>
        </server:default-value>
      </server:property-ui>
    </server:property>

    <server:property name="jsonFormatterScript">
      <server:property-ui type="textAreaBox"
                          label="JSON Formatter Script"
                          description="The script used to format the JSON returned by UrbanCode Deploy into a usable format."
                          hidden="true">
        <server:default-value>
          <![CDATA[
            import org.codehaus.jettison.json.JSONArray
            import org.codehaus.jettison.json.JSONObject
            JSONArray ucdJson = new JSONArray(artifactsJson)
            JSONArray result = new JSONArray()
            for (int i = 0; i < ucdJson.length(); i++) {
                JSONObject old = ucdJson.getJSONObject(i)
                JSONObject newJson = new JSONObject()
                newJson.put("path", old.getString("path"))
                newJson.put("lastModified", old.getLong("lastModified"))
                newJson.put("size", old.getLong("length"))

                result.put(newJson)
            }
            return result
          ]]>
        </server:default-value>
      </server:property-ui>
    </server:property>
  </server:property-group>
</plugin>
