[英]How to create a parameterized job with Jenkins api
我正在使用Jenkins python api創建一個參數化的作業,我可以使用以下config.xml創建一個參數的作業
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description>A build that explores the wonderous possibilities of parameterized builds.</description>
<keepDependencies>false</keepDependencies>
<properties>
<hudson.model.ParametersDefinitionProperty>
<parameterDefinitions>
<hudson.model.StringParameterDefinition>
<name>B</name>
<description>B, like buzzing B.</description>
<defaultValue></defaultValue>
</hudson.model.StringParameterDefinition>
</parameterDefinitions>
</hudson.model.ParametersDefinitionProperty>
</properties>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers class="vector"/>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.tasks.Shell>
<command>ping -c 1 localhost | tee out.txt
echo $A > a.txt
echo $B > b.txt</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.tasks.ArtifactArchiver>
<artifacts>*</artifacts>
<latestOnly>false</latestOnly>
</hudson.tasks.ArtifactArchiver>
<hudson.tasks.Fingerprinter>
<targets></targets>
<recordBuildArtifacts>true</recordBuildArtifacts>
</hudson.tasks.Fingerprinter>
</publishers>
<buildWrappers/>
</project>
我真正想要的是創建一個具有多個參數的作業,我嘗試在此xml中添加並行的<name>
標記,但是實際上它在新作業中創建了一個參數。 我會錯誤地更改xml嗎?
而且,是否可以在api的參數字段中添加預定義的值? 例如,在創建作業后,參數B
的值將為b
。
每個參數都需要自己的hudson.model.StringParameterDefinition部分。 聽起來您正在嘗試將多個名稱放在一個StringParameterDefintion節中,這將不起作用。
如有疑問,請手動創建作業,然后轉到該作業的頁面並附加“ /config.xml”。 您將獲得工作的XML。 讓您的Python復制該代碼,一切就緒。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.