创建源插件

定义源类型插件的方式与定义自动化类型插件的方式相同,只是要对 plugin.xml 文件进行某些修改。

与自动化插件相同,将使用以下三个文件来定义源插件:upgrade.xmlinfo.xmlplugin.xml。头两个文件的结构对于两种插件类型完全相同。plugin.xml 文件的结构随插件的类型而变。本主题中描述了源插件的 plugin.xml 文件的结构。有关自动化插件的 plugin.xml 文件的信息,请参阅自动化插件的 plugin.xml 文件

<server:plugin-type>Source</server:plugin-type> 标记标识插件的类型。对于源插件,类型必须是 Source

<?xml version="1.0" encoding="UTF-8"?>
<!-- the xmlns:server argument is necessary to parse the tags with the server prefix -->
<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.source.Name" name="Plugin Name" version="1"/>
    <description>Short description</description>
    <tag>SCM/Name</tag>
    
    <server:plugin-type>Source</server:plugin-type>
  </header>

   

源插件具有一个步骤,必须将其命名为 Import Version

     <step-type name="Import Version">
      <description>Creates a new component version and imports artifacts</description>
      <properties>
      </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="${JAVA_HOME}/bin/java">
        <arg value="${JAVA_OPTS}"/>
        <arg value="-jar"/>
        <arg file="FileSystemSourceConfig.jar"/>
        <arg value="ImportVersion"/>
        <arg file="${PLUGIN_INPUT_PROPS}"/>
        <arg file="${PLUGIN_OUTPUT_PROPS}"/>
      </command>
      
    </step-type>
    
   

如下以代码片段中所示,源插件具有两个属性组。Component 类型属性使用“创建新组件”窗口进行配置。Import 类型属性使用“导入组件”窗口进行配置。

       
    <!-- ==================================== -->
    <!--   Properties                         -->
    <!-- ==================================== -->
   
    <server:property-group type="Component" name="FileSystemComponentProperties">
      <server:property name="property-name" required="true">
        <server:property-ui type="textBox"
                            label="property-label"
                            description="property-description" />
      </server:property>
    </server:property-group>
    
       <!-- If left empty or omitted then no dialog will appear -->
    <server:property-group type="Import" name="FileSystemImportProperties">
      <server:property name="property-name" required="true">
        <server:property-ui type="textBox"
                            label="property-label"
                            description="property-description" />
      </server:property>
    </server:property-group>
</plugin>

反馈