Create Jenkins Docker Image with pre configured jobs

前端 未结 3 379
渐次进展
渐次进展 2021-02-05 23:11

I have created a bunch of Local deployment pipeline jobs, these jobs do things like remove an existing container, build a service locally, build a docker image, run the containe

相关标签:
3条回答
  • 2021-02-05 23:36

    Jobs need to bootstrapped while the Jenkins starts can be copied to /usr/share/jenkins/ref/jobs/ folder.

    But keep in mind that if the jobs(or any) already exist in Jenkins home folder, updates from /usr/share/jenkins/ref/jobs/ folder won't have any effect unless you end the files with *.override name. https://github.com/jenkinsci/docker/blob/master/jenkins-support#L110

    Dockerfile

    # First time building of jenkins with the preconfigured job
    COPY job_name/config.xml /usr/share/jenkins/ref/jobs/job_name/config.xml
    
    # But if jobs need to be updated, suffix the file names with '.override'.
    COPY job_name/config.xml.override /usr/share/jenkins/ref/jobs/job_name/config.xml.override
    
    0 讨论(0)
  • 2021-02-05 23:53

    For anyone who is interested - I found a better solution. I simply map the jobs folder to a folder on my host, that way I can put the created jobs into source control and edit then add them without having to build a new docker image.

    Sorted.

    0 讨论(0)
  • 2021-02-06 00:00

    I maintain the jobs in a bootstrap folder together with configs etc.

    To add a job (i.e. seedjob) I need to add the following to the Dockerfile:

    # copy seedjob
    COPY bootstrap/seedjob.xml /usr/share/jenkins/ref/jobs/seedjob/config.xml
    
    0 讨论(0)
提交回复
热议问题