美文网首页
How to Automate Jenkins job conf

How to Automate Jenkins job conf

作者: devttao | 来源:发表于2019-03-01 12:57 被阅读0次

    Automatically generating Jenkins jobs: Step-by-step guide

    1. pip install virtualenv
    2. virtualenv .venv
    3. source .venv/bin/activate
    4. pip install jenkins-job-builder
    5. mkdir jenkins-job-auto-create ; cd jenkins-job-auto-create
    6. vim jenkins_jobs.ini

    [job_builder]
    ignore_cache=True
    keep_descriptions=False
    include_path=.
    recursive=False
    allow_duplicates=False
     
    [jenkins]
    user=YOUR_USER_NAME
    password=YOUR_PASSWORD_OR_API_KEY
    url=https://path.to.jenkins
    

    7. vim project_pipeline_test01.yaml

    - job:
        name: Jenkins-auto-config
        project-type: pipeline
        dsl: |
          @Library('CIPipelineUtilities') _
          testSuite {
              envName="BTS_EU"
              suiteName="MonitorTest"
          }
    

    8. jenkins-jobs --conf jenkins_jobs.ini update project_pipeline_test01.yaml

    INFO:jenkins_jobs.cli.subcommand.update:Updating jobs in ['project_pipeline_test01.yaml'] ([])
    INFO:jenkins_jobs.builder:Number of jobs generated:  1
    INFO:jenkins_jobs.builder:Creating jenkins job Jenkins-auto-config
    INFO:jenkins_jobs.cli.subcommand.update:Number of jobs updated: 1
    INFO:jenkins_jobs.builder:Number of views generated:  0
    INFO:jenkins_jobs.cli.subcommand.update:Number of views updated: 0
    

    9. Jenkins job created automatic

    image.png

    10. Configurations as expected

    image.png

    11. Related articles
    https://www.slalom.com/thinking/automatically-generating-jenkins-jobs

    相关文章

      网友评论

          本文标题:How to Automate Jenkins job conf

          本文链接:https://www.haomeiwen.com/subject/iacduqtx.html