<?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.codestation" name="CodeStation" version="12"/>
    <description>The CodeStation plugin provides steps to download and upload artifacts to CodeStation.</description>
    <tag>Build Systems/CodeStation</tag>
  </header>
  
  <!-- ==================================== -->
  <!--   SCM STEPS                          -->
  <!-- ==================================== -->
  <step-type name="Download Dependencies">
    <description>Download dependencies from CodeStation.</description>
    <properties>
      <property name="projectName">
        <server:property-ui type="textBox"
                     label="Project"
                     default-value="${gvy:ProjectLookup.current.name}"
                     description="The name of the project."
                     hidden="true"/>
      </property>
      <property name="workflowName">
        <server:property-ui type="textBox"
                     label="Workflow"
                     default-value="${gvy:BuildLifeLookup.current.originatingWorkflow.name}"
                     description="The name of the workflow."
                     hidden="true"/>
      </property>
      <property name="buildLifeId">
        <server:property-ui type="textBox"
                     label="Build Life"
                     default-value="${gvy:BuildLifeLookup.current.id}"
                     description="The build life identifier to download dependencies from"
                     hidden="true"/>
      </property>
      <property name="permissions" required="true">
        <server:property-ui type="selectBox"
                     label="Permissions"
                     description="Select how you would like CodeStation to handle setting file permissions on download: 
                     None - Don't copy any permissions, 
                     Set All - Set all permissions from the original file, 
                     Set Execute Bits Only - Set only the execute bits from the original file."
                     default-value="NONE" />
        <value label="None">NONE</value>
        <value label="Set All">SET_ALL</value>
        <value label="Set Execute Bits Only">SET_EXECUTE_ONLY</value>
      </property>
      <property name="useCache">
        <server:property-ui type="checkBox"
                        label="Use CodeStation Cache"
                        description="Check this box if you would like to use the local CodeStation cache when downloading dependencies."/>
      </property>
    </properties>
    
    <post-processing><![CDATA[
        if (properties.get("exitCode") == 0) {
            properties.put("Status", "Success");
        }
        else {
            properties.put("Error", "Exit code was " + properties.get("exitCode"));
            properties.put("Status", "Failure");
        }
     ]]></post-processing>
    
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/CommonsFileUtils.jar:lib/CommonsUtil.jar:lib/CommonsXml.jar:lib/asm-3.1.jar:lib/commons-cli-1.2.jar:lib/commons-codec.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/HttpComponents-Util.jar:lib/httpcore.jar:lib/httpmime.jar:lib/commons-logging.jar:lib/jackson-core-asl-1.1.1.jar:lib/jaxb-api.jar:lib/jaxb-impl.jar:lib/jaxb-xjc.jar:lib/jaxb1-impl.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/jersey-guice-1.2.jar:lib/jersey-json-1.2.jar:lib/jersey-server-1.2.jar:lib/jettison-1.1.jar:lib/jsr173_1.0_api.jar:lib/jsr311-api-1.1.1.jar:lib/log4j.jar:lib/lucene-core.jar:lib/ibm-ucb-codestation-client.jar:lib/urbancode-vfs-client.jar:lib/urbancode-vfs-common.jar:lib/commons-lang.jar"/>
      <arg file="DownloadDependencies.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
  
  <step-type name="Upload Artifacts">
    <description>Upload a specific artifact set to CodeStation.</description>
    <properties>
      <property name="projectName">
        <server:property-ui type="textBox"
                     label="Project"
                     default-value="${gvy:ProjectLookup.current.name}"
                     description="The name of the project."
                     hidden="true"/>
      </property>
      <property name="workflowName">
        <server:property-ui type="textBox"
                     label="Workflow"
                     default-value="${gvy:BuildLifeLookup.current.originatingWorkflow.name}"
                     description="The name of the workflow."
                     hidden="true"/>
      </property>
      <property name="buildLifeId">
        <server:property-ui type="textBox"
                     label="Build Life"
                     default-value="${gvy:BuildLifeLookup.current.id}"
                     description="The build life identifier to download dependencies from"
                     hidden="true"/>
      </property>
      <property name="setName" required="true">
        <server:property-ui type="textBox"
                     label="Artifact Set Name"
                     description="The artifact set name"/>
      </property>
      <property name="additionalHashes">
        <server:property-ui type="multiSelectBox"
                     label="Additional Hashes"
                     description="Select additional hashes that you would like to capture other than the default of SHA-256."/>
        <value label="MD5">MD5</value>
        <value label="SHA-1">SHA-1</value>
      </property>
      <property name="symlinks" required="true">
        <server:property-ui type="selectBox"
                     label="Symlinks"
                     description="Select how you would like CodeStation to handle uploading symlinks: 
                     As Link - Symlinks are inluded in the list as symlinks, 
                     Exclude - Symlinks and the files or directories that they point to are excluded, 
                     Follow - Symlinks are treated as regular files or directories."
                     default-value="AS_LINK" />
        <value label="As Link">AS_LINK</value>
        <value label="Exclude">EXCLUDE</value>
        <value label="Follow">FOLLOW</value>
      </property>
      <property name="directories" required="true">
        <server:property-ui type="selectBox"
                     label="Directories"
                     description="Select how you would like CodeStation to handle uploading directories: 
                     Exclude - No directories are included in the file list, 
                     Include All - All directories, empty or not, are included in the file list, 
                     Include Non-Empty - Non-empty directories are included in the file list."
                     default-value="INCLUDE_ALL" />
        <value label="Exclude">EXCLUDE</value>
        <value label="Include All">INCLUDE_ALL</value>
        <value label="Include Non-Empty">INCLUDE_NON_EMPTY</value>
      </property>
      <property name="permissions" required="true">
        <server:property-ui type="selectBox"
                     label="Permissions"
                     description="Select how you would like CodeStation to handle uploading permissions: 
                     Best Effort - Attempt to read permissions, but failures are non-fatal, 
                     File Execute Only - Attempt to read file execute permission, but failures are non-fatal, 
                     None - No permissions are read, 
                     Required - Permissions must be read successfully."
                     default-value="NONE" />
        <value label="Best Effort">BEST_EFFORT</value>
        <value label="File Execute Only">FILE_EXECUTE_ONLY</value>
        <value label="None">NONE</value>
        <value label="Required">REQUIRED</value>
      </property>
      <property name="failIfNotFound">
        <server:property-ui type="checkBox"
                            label="Fail If Not Found"
                            description="Force the upload step to fail when the directory containing artifacts does 
                            not exist or there are no artifacts in the directory."
                            default-value="false"/>
      </property>
    </properties>
    
    <post-processing><![CDATA[
        if (properties.get("exitCode") == 0) {
            properties.put("Status", "Success");
        }
        else {
            properties.put("Error", "Exit code was " + properties.get("exitCode"));
            properties.put("Status", "Failure");
        }
     ]]></post-processing>
    
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/CommonsFileUtils.jar:lib/CommonsUtil.jar:lib/CommonsXml.jar:lib/asm-3.1.jar:lib/commons-cli-1.2.jar:lib/commons-codec.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/HttpComponents-Util.jar:lib/httpcore.jar:lib/httpmime.jar:lib/commons-logging.jar:lib/jackson-core-asl-1.1.1.jar:lib/jaxb-api.jar:lib/jaxb-impl.jar:lib/jaxb-xjc.jar:lib/jaxb1-impl.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/jersey-guice-1.2.jar:lib/jersey-json-1.2.jar:lib/jersey-server-1.2.jar:lib/jettison-1.1.jar:lib/jsr173_1.0_api.jar:lib/jsr311-api-1.1.1.jar:lib/log4j.jar:lib/lucene-core.jar:lib/ibm-ucb-codestation-client.jar:lib/urbancode-vfs-client.jar:lib/urbancode-vfs-common.jar:lib/commons-lang.jar"/>
      <arg file="UploadArtifactSet.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
  
  <step-type name="Upload All Artifacts">
    <description>Upload all configured artifact sets to CodeStation.</description>
    <properties>
      <property name="projectName">
        <server:property-ui type="textBox"
                     label="Project"
                     default-value="${gvy:ProjectLookup.current.name}"
                     description="The name of the project."
                     hidden="true"/>
      </property>
      <property name="workflowName">
        <server:property-ui type="textBox"
                     label="Workflow"
                     default-value="${gvy:BuildLifeLookup.current.originatingWorkflow.name}"
                     description="The name of the workflow."
                     hidden="true"/>
      </property>
      <property name="buildLifeId">
        <server:property-ui type="textBox"
                     label="Build Life"
                     default-value="${gvy:BuildLifeLookup.current.id}"
                     description="The build life identifier to download dependencies from"
                     hidden="true"/>
      </property>
      <property name="additionalHashes">
        <server:property-ui type="multiSelectBox"
                     label="Additional Hashes"
                     description="Select additional hashes that you would like to capture other than the default of SHA-256."/>
        <value label="MD5">MD5</value>
        <value label="SHA-1">SHA-1</value>
      </property>
      <property name="symlinks" required="true">
        <server:property-ui type="selectBox"
                     label="Symlinks"
                     description="Select how you would like CodeStation to handle uploading symlinks: 
                     As Link - Symlinks are inluded in the list as symlinks, 
                     Exclude - Symlinks and the files or directories that they point to are excluded, 
                     Follow - Symlinks are treated as regular files or directories."
                     default-value="AS_LINK" />
        <value label="As Link">AS_LINK</value>
        <value label="Exclude">EXCLUDE</value>
        <value label="Follow">FOLLOW</value>
      </property>
      <property name="directories" required="true">
        <server:property-ui type="selectBox"
                     label="Directories"
                     description="Select how you would like CodeStation to handle uploading directories: 
                     Exclude - No directories are included in the file list, 
                     Include All - All directories, empty or not, are included in the file list, 
                     Include Non-Empty - Non-empty directories are included in the file list."
                     default-value="INCLUDE_ALL" />
        <value label="Exclude">EXCLUDE</value>
        <value label="Include All">INCLUDE_ALL</value>
        <value label="Include Non-Empty">INCLUDE_NON_EMPTY</value>
      </property>
      <property name="permissions" required="true">
        <server:property-ui type="selectBox"
                     label="Permissions"
                     description="Select how you would like CodeStation to handle uploading permissions: 
                     Best Effort - Attempt to read permissions, but failures are non-fatal, 
                     File Execute Only - Attempt to read file execute permission, but failures are non-fatal, 
                     None - No permissions are read, 
                     Required - Permissions must be read successfully."
                     default-value="NONE" />
        <value label="Best Effort">BEST_EFFORT</value>
        <value label="File Execute Only">FILE_EXECUTE_ONLY</value>
        <value label="None">NONE</value>
        <value label="Required">REQUIRED</value>
      </property>
    </properties>
    
    <post-processing><![CDATA[
        if (properties.get("exitCode") == 0) {
            properties.put("Status", "Success");
        }
        else {
            properties.put("Error", "Exit code was " + properties.get("exitCode"));
            properties.put("Status", "Failure");
        }
     ]]></post-processing>
    
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/CommonsFileUtils.jar:lib/CommonsUtil.jar:lib/CommonsXml.jar:lib/asm-3.1.jar:lib/commons-cli-1.2.jar:lib/commons-codec.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/HttpComponents-Util.jar:lib/httpcore.jar:lib/httpmime.jar:lib/commons-logging.jar:lib/jackson-core-asl-1.1.1.jar:lib/jaxb-api.jar:lib/jaxb-impl.jar:lib/jaxb-xjc.jar:lib/jaxb1-impl.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/jersey-guice-1.2.jar:lib/jersey-json-1.2.jar:lib/jersey-server-1.2.jar:lib/jettison-1.1.jar:lib/jsr173_1.0_api.jar:lib/jsr311-api-1.1.1.jar:lib/log4j.jar:lib/lucene-core.jar:lib/ibm-ucb-codestation-client.jar:lib/urbancode-vfs-client.jar:lib/urbancode-vfs-common.jar:lib/commons-lang.jar"/>
      <arg file="UploadAllArtifactSets.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
  
  <step-type name="Download Artifacts">
    <description>Download artifact set files from CodeStation.</description>
    <properties>
      <property name="projectName">
        <server:property-ui type="textBox"
                     label="Project"
                     default-value="${gvy:ProjectLookup.current.name}"
                     description="The name of the project."
                     hidden="true"/>
      </property>
      <property name="workflowName">
        <server:property-ui type="textBox"
                     label="Workflow"
                     default-value="${gvy:BuildLifeLookup.current.originatingWorkflow.name}"
                     description="The name of the workflow."
                     hidden="true"/>
      </property>
      <property name="buildLifeId">
        <server:property-ui type="textBox"
                     label="Build Life"
                     default-value="${gvy:BuildLifeLookup.current.id}"
                     description="The build life identifier to download artifacts from"
                     hidden="true"/>
      </property>
      <property name="artifactSetName">
        <server:property-ui type="textBox"
                     label="Artifact Set"
                     description="The artifact set to download."/>
      </property>
      <property name="permissions" required="true">
        <server:property-ui type="selectBox"
                     label="Permissions"
                     description="Select how you would like CodeStation to handle setting file permissions on download: 
                     None - Don't copy any permissions, 
                     Set All - Set all permissions from the original file, 
                     Set Execute Bits Only - Set only the execute bits from the original file."
                     default-value="NONE" />
        <value label="None">NONE</value>
        <value label="Set All">SET_ALL</value>
        <value label="Set Execute Bits Only">SET_EXECUTE_ONLY</value>
      </property>
      <property name="useCache">
        <server:property-ui type="checkBox"
                        label="Use CodeStation Cache"
                        description="Check this box if you would like to use the local CodeStation cache when downloading dependencies."/>
      </property>
    </properties>
    
    <post-processing><![CDATA[
        if (properties.get("exitCode") == 0) {
            properties.put("Status", "Success");
        }
        else {
            properties.put("Error", "Exit code was " + properties.get("exitCode"));
            properties.put("Status", "Failure");
        }
     ]]></post-processing>
    
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/CommonsFileUtils.jar:lib/CommonsUtil.jar:lib/CommonsXml.jar:lib/asm-3.1.jar:lib/commons-cli-1.2.jar:lib/commons-codec.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/HttpComponents-Util.jar:lib/httpcore.jar:lib/httpmime.jar:lib/commons-logging.jar:lib/jackson-core-asl-1.1.1.jar:lib/jaxb-api.jar:lib/jaxb-impl.jar:lib/jaxb-xjc.jar:lib/jaxb1-impl.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/jersey-guice-1.2.jar:lib/jersey-json-1.2.jar:lib/jersey-server-1.2.jar:lib/jettison-1.1.jar:lib/jsr173_1.0_api.jar:lib/jsr311-api-1.1.1.jar:lib/log4j.jar:lib/lucene-core.jar:lib/ibm-ucb-codestation-client.jar:lib/urbancode-vfs-client.jar:lib/urbancode-vfs-common.jar:lib/commons-lang.jar"/>
      <arg file="DownloadArtifactSet.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Download Another Project Artifacts">
    <description>Download artifact set files from a different CodeStation project.</description>
    <properties>
      <property name="projectName">
        <server:property-ui type="textBox"
                     label="Project"
                     description="The name of the project."/>
      </property>
      <property name="workflowName">
        <server:property-ui type="textBox"
                     label="Workflow"
                     description="The name of the workflow."/>
      </property>
      <property name="buildLifeId">
        <server:property-ui type="textBox"
                     label="Build Life"
                     description="The build life identifier to download artifacts from."
                     />
      </property>
      <property name="codestationProjectName">
        <server:property-ui type="textBox"
                     label="CodeStation Project"
                     description="The name of the CodeStation project."/>
      </property>
      <property name="codestationBuildLifeId">
        <server:property-ui type="textBox"
                     label="CodeStation Build Life"
                     description="The CodeStation build life identifier to download artifacts from."
                     />
      </property>
      <property name="buildLifeStamp">
        <server:property-ui type="textBox"
                     label="Build Life with Stamp"
                     description="The stamp pattern to use for selecting a build life to download."
                     />
      </property>
      <property name="buildLifeStatus">
        <server:property-ui type="textBox"
                     label="Build Life with Status"
                     description="The status name to use for selecting a build life to download"
                     />
      </property>
      <property name="buildLifeLabel">
        <server:property-ui type="textBox"
                     label="Build Life with Label"
                     description="The label name to use for selecting a build life to download"
                     />
      </property>
      <property name="artifactSetName" required="true">
        <server:property-ui type="textBox"
                     label="Artifact Set"
                     description="The artifact set to download."/>
      </property>
      <property name="permissions" required="true">
        <server:property-ui type="selectBox"
                     label="Permissions"
                     description="Select how you would like CodeStation to handle setting file permissions on download: 
                     None - Don't copy any permissions, 
                     Set All - Set all permissions from the original file, 
                     Set Execute Bits Only - Set only the execute bits from the original file."
                     default-value="NONE" />
        <value label="None">NONE</value>
        <value label="Set All">SET_ALL</value>
        <value label="Set Execute Bits Only">SET_EXECUTE_ONLY</value>
      </property>
      <property name="useCache">
        <server:property-ui type="checkBox"
                        label="Use CodeStation Cache"
                        description="Check this box if you would like to use the local CodeStation cache when downloading artifacts"/>
      </property>
    </properties>
    
    <post-processing><![CDATA[
        if (properties.get("exitCode") == 0) {
            properties.put("Status", "Success");
        }
        else {
            properties.put("Error", "Exit code was " + properties.get("exitCode"));
            properties.put("Status", "Failure");
        }
     ]]></post-processing>
    
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/CommonsFileUtils.jar:lib/CommonsUtil.jar:lib/CommonsXml.jar:lib/asm-3.1.jar:lib/commons-cli-1.2.jar:lib/commons-codec.jar:lib/httpclient.jar:lib/httpclient-cache.jar:lib/HttpComponents-Util.jar:lib/httpcore.jar:lib/httpmime.jar:lib/commons-logging.jar:lib/jackson-core-asl-1.1.1.jar:lib/jaxb-api.jar:lib/jaxb-impl.jar:lib/jaxb-xjc.jar:lib/jaxb1-impl.jar:lib/jersey-client-1.2.jar:lib/jersey-core-1.2.jar:lib/jersey-guice-1.2.jar:lib/jersey-json-1.2.jar:lib/jersey-server-1.2.jar:lib/jettison-1.1.jar:lib/jsr173_1.0_api.jar:lib/jsr311-api-1.1.1.jar:lib/log4j.jar:lib/lucene-core.jar:lib/ibm-ucb-codestation-client.jar:lib/urbancode-vfs-client.jar:lib/urbancode-vfs-common.jar:lib/commons-lang.jar"/>
      <arg file="DownloadArtifactSet.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

</plugin>
