<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed Materials - Property of IBM Corp.
- IBM UrbanCode Deploy
- (c) Copyright IBM Corporation 2014, 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">
  <header>
    <identifier id="com.ibm.urbancode.air.plugin.Artifactory" name="Artifactory" version="3"/>
    <description>The Artifactory plug-in includes steps for downloading artifacts from Artifactory repositories. For additional help, see the artifactory_plugin_v1.pdf file in the plug-in archive file.</description>
    <tag>Repositories/Artifact/Artifactory</tag>
  </header>
  <!-- ==================================== -->
  <!--   SCM STEPS                          -->
  <!-- ==================================== -->
  <step-type name="Download version (Maven build)">
    <description>Download all files under a specified version of a repository that was built with Maven.</description>
    <properties>
      <property name="artifactoryUrl" required="true">
        <property-ui type="textBox" label="Artifactory URL" default-value="${p:component/ArtifactoryComponentProperties/repoUrl}"
                     description="The base URL of the Artifactory server. For example:
                                  http://server.example.com:8081/artifactory"/>
      </property>
      <property name="repositoryName">
        <property-ui type="textBox" label="Repository name"
                     default-value="${p:component/ArtifactoryComponentProperties/repoName}"
                     description="The name of the repository."/>
      </property>
      <property name="artifacts" required="true">
        <property-ui type="textAreaBox" label="Versions"
                     description="A list of versions to download, separated by newline characters. Use the following format:
                                  groupId/artifactId/version"/>
      </property>
      <property name="checkHash">
        <property-ui type="checkBox" label="Verify Hash"
                     description="Select to verify hash values after the files are downloaded."/>
      </property>
      <property name="username">
        <property-ui type="textBox" label="Repository User name"
                     default-value="${p:component/ArtifactoryComponentProperties/user}"
                     description="The user name to authenticate with Artifactory."/>
      </property>
      <property name="password">
        <property-ui type="secureBox" label="Repository Password"
                     default-value="${p:component/ArtifactoryComponentProperties/password}"
                     description="The password to authenticate with Artifactory."/>
      </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/httpclient.jar:lib/httpcore.jar:lib/HttpComponents-Util.jar:lib/commons-codec.jar:lib/CommonsUtil.jar:lib/CommonsFileUtils.jar:lib/log4j.jar:lib/commons-lang.jar"/>
      <arg file="artifactory_maven_download.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Download version (non-Maven build)">
    <description>Download all files under specified version of a repository (non-Maven).</description>
    <properties>
      <property name="artifactoryUrl" required="true">
        <property-ui type="textBox" label="Artifactory URL" default-value="${p:component/ArtifactoryComponentProperties/repoUrl}"
                     description="The base URL of the Artifactory server. For example:
                                  http://server.example.com:8081/artifactory"/>
      </property>
      <property name="repositoryName" required="true">
        <property-ui type="textBox" label="Repository name"
                     default-value="${p:component/ArtifactoryComponentProperties/repoName}"
                     description="The name of the repository."/>
      </property>
      <property name="artifacts" required="true">
        <property-ui type="textAreaBox" label="Versions"
                     description="A list of versions to download, separated by newline characters. Use the following format:
                                  groupId/artifactId/version"/>
      </property>
      <property name="checkHash">
        <property-ui type="checkBox" label="Verify Hash"
                     description="Select to verify hash values after the files are downloaded."/>
      </property>
      <property name="username">
        <property-ui type="textBox" label="Repository User name"
                     default-value="${p:component/ArtifactoryComponentProperties/user}"
                     description="The user name to authenticate with Artifactory."/>
      </property>
      <property name="password">
        <property-ui type="secureBox" label="Repository Password"
                     default-value="${p:component/ArtifactoryComponentProperties/password}"
                     description="The password to authenticate with Artifactory."/>
      </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/httpclient.jar:lib/httpcore.jar:lib/HttpComponents-Util.jar:lib/commons-codec.jar:lib/CommonsUtil.jar:lib/CommonsFileUtils.jar:lib/log4j.jar:lib/commons-lang.jar"/>
      <arg file="artifactory_non_maven_download.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Download NuGet package">
    <description>Download a NuGet package from a NuGet repository.</description>
    <properties>
      <property name="artifactoryUrl" required="true">
        <property-ui type="textBox" label="Artifactory URL" default-value="${p:component/ArtifactoryComponentProperties/repoUrl}"
                     description="The base URL of the Artifactory server. For example:
                                  http://server.example.com:8081/artifactory"/>
      </property>
      <property name="artifacts" required="true">
        <property-ui type="textAreaBox" label="Packages"
                     description="A list of packages to download, separated by newline characters. Use the following format:
                                  groupId/artifactId/version"/>
      </property>
      <property name="checkHash">
        <property-ui type="checkBox" label="Verify Hash"
                     description="Select to verify hash values after the files are downloaded."/>
      </property>
      <property name="username">
        <property-ui type="textBox" label="Repository User name"
                     default-value="${p:component/ArtifactoryComponentProperties/user}"
                     description="The user name to authenticate with Artifactory."/>
      </property>
      <property name="password">
        <property-ui type="secureBox" label="Repository Password"
                     default-value="${p:component/ArtifactoryComponentProperties/password}"
                     description="The password to authenticate with Artifactory."/>
      </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/httpclient.jar:lib/httpcore.jar:lib/HttpComponents-Util.jar:lib/commons-codec.jar:lib/CommonsUtil.jar:lib/CommonsFileUtils.jar:lib/log4j.jar:lib/commons-lang.jar"/>
      <arg file="nuget_download.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

  <step-type name="Promote Build">
    <description>Change the status of a build, optionally moving or copying the build to a target repository.</description>
    <properties>
      <property name="url" required="true">
        <property-ui type="textBox" label="Artifactory URL"
                     default-value="${p:component/ArtifactoryComponentProperties/repoUrl}"
                     description="The base URL of the Artifactory server. For example:
                                  http://server.example.com:8081/artifactory"/>
      </property>
      <property name="username">
        <property-ui type="textBox" label="User Name"
                     default-value="${p:component/ArtifactoryComponentProperties/user}"
                     description="The user name to authenticate with the Artifactory server."/>
      </property>
      <property name="password">
        <property-ui type="secureBox" label="Password"
                     default-value="${p:component/ArtifactoryComponentProperties/password}"
                     description="The password to authenticate with the Artifactory server."/>
      </property>
      <property name="buildName" required="true">
        <property-ui type="textBox" label="Build Name"
                     description="The name of the build to promote."/>
      </property>
      <property name="buildNumber" required="true">
        <property-ui type="textBox" label="Build Number"
                     description="The number of the build to promote."/>
      </property>
      <property name="buildStatus" required="true">
        <property-ui type="textBox" label="Status"
                     description="New build status."/>
      </property>
      <property name="buildUser">
        <property-ui type="textBox" label="CI User"
                     default-value="${p:request.user.name}"
                     description="User that invoked promotion from the CI server."/>
      </property>
      <property name="buildComment">
        <property-ui type="textBox" label="Comment"
                     description="Comment to describe the reason for promotion."/>
      </property>
      <property name="buildSource">
        <property-ui type="textBox" label="Source Repository"
                     description="The source repository that contains the build artifacts to copy or move."/>
      </property>
      <property name="buildTarget">
        <property-ui type="textBox" label="Target Repository"
                     description="The target repository for the build artifacts and dependencies."/>
      </property>
      <property name="buildArtifact">
        <property-ui type="checkBox" label="Include Artifacts"
                     description="Select to move or copy the build artifacts."/>
      </property>
      <property name="buildDepend">
        <property-ui type="checkBox" label="Include Dependencies"
                     description="Select to move or copy the build dependencies."/>
      </property>
      <property name="buildCopy">
        <property-ui type="checkBox" label="Copy"
                     description="Select to copy instead of move when a target repository is specified."/>
      </property>
      <property name="buildDryrun">
        <property-ui type="checkBox" label="Dry Run"  hidden="true"
                     description="Select to get results only to verify that the operation can succeed. No operation is run in
                                  Artifactory."/>
      </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/httpclient.jar:lib/httpcore.jar:lib/HttpComponents-Util.jar:lib/commons-codec.jar:lib/CommonsUtil.jar:lib/CommonsFileUtils.jar:lib/log4j.jar:lib/commons-lang.jar"/>
      <arg file="promote.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
  <step-type name="Set Item Properties">
    <description>Attach properties to a file or folder.</description>
    <properties>
      <property name="url" required="true">
        <property-ui type="textBox" label="Artifactory URL"
                     default-value="${p:component/ArtifactoryComponentProperties/repoUrl}"
                     description="The base URL of the Artifactory server. For example:
                                  http://server.example.com:8081/artifactory"/>
      </property>
      <property name="username">
        <property-ui type="textBox" label="User Name"
                     default-value="${p:component/ArtifactoryComponentProperties/user}"
                     description="The user name to authenticate with the Artifactory server."/>
      </property>
      <property name="password">
        <property-ui type="secureBox" label="Password"
                     default-value="${p:component/ArtifactoryComponentProperties/password}"
                     description="The password to authenticate with the Artifactory server."/>
      </property>
      <property name="path" required="true">
        <property-ui type="textBox" label="Artifact Path"
                     description="The path to the artifact to set properties on. For example:
                                  libs-release-local/org/jfrog/multi1/2.7-SNAPSHOT"/>
      </property>
      <property name="properties" required="true">
        <property-ui type="textAreaBox" label="Properties"
                     description="Specify a list of properties to set. Place each entry on a separate line. Use the following
                                  format: key=value. Separate multiple values for a key with commas, and add a backslash (\)
                                  before the following special characters: comma (,), backslash(\), vertical bar (|), and equal
                                  sign (=). Do not use a backslash before the equal sign between the key and the value or before
                                  commas used to separate multiple values. For example:
                                  osVersions=Windows\=7\,10,Linux\=16.04 LTS\"/>
      </property>
      <property name="recursive">
        <property-ui type="checkBox" label="Recursive"
                     description="Select to attach properties recursively if the Artifact Path is a directory."/>
      </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/httpclient.jar:lib/httpcore.jar:lib/HttpComponents-Util.jar:lib/commons-codec.jar:lib/CommonsUtil.jar:lib/CommonsFileUtils.jar:lib/log4j.jar:lib/commons-lang.jar"/>
      <arg file="setProperties.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>
</plugin>
