2015-12-21 13 views
5

誰かが私に有用なリンクを教えてもらえますか?複合体の変換についての情報がありますか? Jenkinsジョブのxml構成ですか?ここでJenkins xmlの設定をGroovyベースのJenkinsジョブDSL

はジェンキンスジョブの例です:私の経験で

<project> 
    <actions/> 
    <description>Description</description> 
    <logRotator class="hudson.tasks.LogRotator"> 
     <!-- ...--> 
    </logRotator> 
    <keepDependencies>false</keepDependencies> 
    <properties> 
     <hudson.model.ParametersDefinitionProperty/><!-- ...--> 
    </properties> 
    <scm class="org.jenkinsci.plugins.multiplescms.MultiSCM" plugin="[email protected]"> 
     <scms> 
      <hudson.plugins.git.GitSCM plugin="[email protected]"/><!-- ...--> 
      <hudson.plugins.git.GitSCM plugin="[email protected]"/><!-- ...--> 
     </scms> 
    </scm> 
    <canRoam>true</canRoam> 
    <disabled>false</disabled> 
    <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> 
    <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> 
    <jdk>Default</jdk> 
    <triggers> 
     <hudson.triggers.TimerTrigger/><!-- ...--> 
    </triggers> 
    <concurrentBuild>false</concurrentBuild> 
    <customWorkspace>$HUDSON_WD/$REVISION/checkout</customWorkspace> 
    <builders/> 
    <publishers> 
     <hudson.plugins.globalenvvar.GlobalEnvironmentVariablePublisher plugin="[email protected]"/><!-- ...-->    
     <hudson.plugins.parameterizedtrigger.BuildTrigger plugin="[email protected]"/><!-- ...--> 
     <hudson.plugins.templateproject.ProxyPublisher plugin="[email protected]"/><!-- ...--> 
    </publishers> 
    <buildWrappers> 
     <hudson.plugins.timestamper.TimestamperBuildWrapper plugin="[email protected]"/> 
    </buildWrappers> 
</project> 
+2

はどのようにあなたはジェンキンス仕事DSLにジェンキンスであなたの現在の仕事を変換するか、でしょうか? –

+0

@スティーブ・キャンベル、はい。 – Arthur

答えて

9

、それは再書き込みの完全手動のプロセスです。参考資料はhttps://jenkinsci.github.io/job-dsl-plugin/#です。

xmlの多くの要素がデフォルトに設定されているため、xmlの多くはスキップできます。 DSLがあなたが設定したプラグインのプラグインまたは機能を直接サポートしていない場合は、要素ごとにXMLを変換するだけで済みます。 (ジェンキンスGUIを介して)設定された各プロパティを通じて

  1. 進み、例えば次のよう

    変換処理であります"古いビルドを破棄する"。

  2. DSLにその要素のネイティブサポートがあるかどうかを判断します。その場合は、DSLで書き換えてください。たとえば、logRotatorは「古いビルドを破棄する」機能を提供します。
  3. DSLで直接サポートされていない場合は、configureを手動で使用してxmlを出力する必要があります。これは非常に扱いにくく、可能な限り避けるべきです。

ジョブ要素を提供しているプラ​​グインがわからない場合は、その要素のヘルプテキストにプラグイン名が表示されることがよくあります(小さな疑問符アイコンをクリックしてください)。それ以外の場合は、xml要素にプラグイン名が含まれることがよくあります。

また、Jenkinsの設定画面にあるように、DSLで同じようにジョブ要素が分割されていることをお勧めします。したがって、それがトリガーの場合は、triggersのDSLで見つけることができます。

簡単な例(私が知っている、あなたは、はるかに複雑である):私はあなたが求めているものだと思い

freeStyleJob("Arthur's Example") { 
    description('Description') 
    logRotator(30) 
} 
関連する問題