更新01:
这现在是
Subversion Plugin
那艘船
jenkins/hudson.war
.
代替HudSon插件(我不知道Java),XSL(1)怎么样?在以下解决方案中:
-
我们通过
svn list --xml
,保存到svn-list.xml
-
我们运行一个转换,将svn-list.xml转换为hudson的内部模式以供选择下拉列表,保存到hudson-list.xml。
-
我们运行另一个转换,根据要更新的列表的特定名称将hudson-list.xml加入到作业的config.xml中,保存到new-config.xml,并使用新的config更新hudson作业。
1。
VPN列表——XML
svn list [path-to-svn-tag-directory] --xml > svn-list.xml
2。将SVN列表转换为Hudson列表
xsltproc svn-to-hudson.xsl svn-list.xml > hudson-list.xml
svn-to-hudson.xsl
:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/lists/list">
<hudson.model.ChoiceParameterDefinition>
<name>[Your Name for the List]</name>
<description/>
<choices class="java.util.Arrays$ArrayList">
<a class="string-array">
<xsl:apply-templates select="entry"/>
</a>
</choices>
</hudson.model.ChoiceParameterDefinition>
</xsl:template>
<xsl:template match="entry">
<string>
<xsl:value-of select="name"/>
</string>
</xsl:template>
</xsl:stylesheet>
三。用job的config.xml加入hudson列表
以下用途
curl
要获取旧的config.xml并发布新的config.xml,请使用Hudson的作业API修改配置。
curl -o old-config.xml http://[your-hudson-server]/job/[job-name]/config.xml -u [username]:[password]
xsltproc join.xsl old-config.xml > new-config.xml
curl -X POST -d @new-config.xml http://[your-hudson-server]/job/[job-name]/config.xml -u [username]:[password]
join.xsl要求在同一目录中存在hudson-list.xml:
<xsl:variable name="tag-list" select="document('hudson-list.xml')"/>
您还需要修改
<xsl:variable name="list-name" select="string('Name')"/>
到作业中列表的名称(例如,“SVN标记”、“标记的构建”等)。
XSL
:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="tag-list" select="document('hudson-list.xml')"/>
<xsl:variable name="list-name" select="string('Name')"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="hudson.model.ChoiceParameterDefinition">
<xsl:choose>
<xsl:when test="name = $list-name"> <!-- If the name matches, swap in new list -->
<xsl:copy-of select="$tag-list"/>
</xsl:when>
<xsl:otherwise> <!-- If the name does not match, copy what's already there -->
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
我希望这个端到端的解决方案对您有效。
谢谢您,
扎卡里