[英]Is there a plugin for listing subversion tags in Hudson?
在Hudson中,我們有一個將指定的subversion標記部署到服務器的作業。 此標記目前在文本字段中輸入,但由於這只是一個等待發生的輸入錯誤,我們希望該文本字段被包含當前可用標記的下拉列表替換。 也就是說,我們希望Hudson轉到<subversion repo url> / tags並獲取在那里找到的所有標簽。
我已經搜索了一個Hudson插件或其他一些方法來實現這一目標,但沒有成功。 這不是第一次有人想要這個,對嗎? 或者由於某些我目前無法想到的原因,這會被視為不良做法嗎?
編輯
其他人確實有同樣的想法(僅在三周前),但目前還沒有發布解決方案: http : //issues.hudson-ci.org/browse/HUDSON-6682?page = com.atlassian.jira.plugin .system.issuetabpanels%3Aall-一個tabpanel
編輯2
我現在已經實現了Zachary Young的答案,經過對環境的一些修改后,它完美無缺。
我們的修改:
我們有以UTF-8編碼的國際內容,我不得不將其添加到join.xsl:
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
以及上傳新配置的curl命令:
curl -H "Content-Type: text/xml; charset=UTF-8" -X POST --data-binary @$WORKING_DIR/new-config.xml $HUDSON_CONFIG_PATH -u $USER:$PASSWORD
這至少是我現在所記得的。
現在將它放在一個外部腳本中,但是我將它放在一個Hudson作業中,以便其他開發人員可以輕松地運行它。
我敦促大家贊成Zachary Young的回答 !
更新01:
現在這是與jenkins/hudson.war
一起提供的Subversion插件的一部分。
代替Hudson插件(我不懂Java),一些XSL(1.0)怎么樣? 在以下解決方案中:
svn list --xml
獲取標簽的目錄列表,保存到svn-list.xml 1. svn list --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>
3.使用Job的config.xml加入Hudson List
以下使用curl
來獲取舊的config.xml,並使用Hudson的作業API修改配置來發布新的config.xml。
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標簽','標記構建'等...)。
join.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>
我希望這種端到端解決方案適合您。
謝謝,
扎卡里
如何批處理任務插件 。 這將允許您轉到Hudson中的任何構建(當前和舊構建)並在該構建上運行批處理。 批次是預定義的任務。
這只適用於你的目的,如果Hudson正在創建你的官方版本並在subversion中標記它。 當然,僅適用於尚未刪除的版本。 ;)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.