答えて

1

git repoを使用している場合、repoのルートディレクトリにJenkinsfileというファイルを追加します。これにはあなたの仕事dslが含まれているはずです。

16

pipelineJobを使用してください。

例:

pipelineJob('Pipeline') { 
    definition { 
    cps { 
     sandbox() 
     script(""" 
     node { 
      stage('init') { 
      build 'Pipeline-init' 
      } 
      stage('build') { 
      build 'Pipeline-build' 
      } 
     } 
     """.stripIndent())  
    } 
    } 
} 
4

私はこの質問はどのようにプロジェクトのためJenkinsfileを参照するパイプラインジョブを作成するには、ジョブDSLを使用するために何かを求めている、と詳細と雇用創出を結合しないと考えていますこれまでの回答で示されているように、ステップの定義。これは理にかなっています.Jenkinsのジョブの作成とメタデータの設定(説明、トリガーなど)はJenkinsの管理者に属している可能性がありますが、開発チームはジョブの実際の操作を制御する必要があります。

@meallhourは、あなたが何をしているのですか? (仕事DSL 1.64でとして働く)

pipelineJob('DSL_Pipeline') { 

    def repo = 'https://github.com/path/to/your/repo.git' 

    triggers { 
    scm('H/5 * * * *') 
    } 
    description("Pipeline for $repo") 

    definition { 
    cpsScm { 
     scm { 
     git { 
      remote { url(repo) } 
      branches('master', '**/feature*') 
      scriptPath('misc/Jenkinsfile.v2') 
      extensions { } // required as otherwise it may try to tag the repo, which you may not want 
     } 

     // the single line below also works, but it 
     // only covers the 'master' branch and may not give you 
     // enough control. 
     // git(repo, 'master', { node -> node/'extensions' << '' }) 
     } 
    } 
    } 
} 

参考仕事DSL pipelineJob:https://jenkinsci.github.io/job-dsl-plugin/#path/pipelineJob、および生成された設定を確認するためにhttp://job-dsl.herokuapp.com/にそれをハック。

この例は私に役立ちました。ここでは私のために働いたものに基づいて別の例です:

pipelineJob('Your App Pipeline') { 

    def repo = 'https://github.com/user/yourApp.git' 
    def sshRepo = '[email protected]:user/yourApp.git' 

    description("Your App Pipeline") 
    keepDependencies(false) 

    properties{ 

    githubProjectUrl (repo) 
    rebuild { 
     autoRebuild(false) 
    } 
    } 

    definition { 

    cpsScm { 
     scm { 
     git { 
      remote { url(sshRepo) } 
      branches('master') 
      scriptPath('Jenkinsfile') 
      extensions { } // required as otherwise it may try to tag the repo, which you may not want 
     } 
     } 
    } 
    } 

あなたがUIを介して第1のパイプラインを構築する場合、あなたはパイプラインのジョブを作成するために、config.xmlファイルとジェンキンスドキュメントhttps://jenkinsci.github.io/job-dsl-plugin/#path/pipelineJobを使用することができます。

関連する問題