Generate Jenkins jobs based on github repos
439
This example uses the Job DSL Plugin and the Java API for GitHub to generate Jenkins jobs based on github repos.
Check out the blog article for this example.
managedJobs.groovy which generates the job generate-org-jobsgenerate-org-jobs for a github organization, it searches the github organization for gradle files and generate Jenkins jobs for each repo found..
├── jenkins-home
│ ├── init.groovy.d
│ │ └── startup.groovy # install gradle, deploy config files, run the seed job
│ ├── jobs
│ │ └── seed # seed job definition (should be the only config.xml)
│ ├── config-file-provider
│ │ └── generate-jobs-for-org.groovy # script to generate Jenkins jobs for a given org
│ │ └── github-lib-build.gradle # build file to download github-api jars so it can be used by DSL
│ ├── dsl
│ │ └── managedJobs.groovy # dsl script to create `generate-org-jobs`
│ └── plugins.txt # jenkins plugins
└── Dockerfile # build the Docker image
./gradlew dockerBuild dockerRun Build the docker image locally and start Jenkins at http://localhost:8080/Using the ability to programmatically generate Jenkins jobs from your github source repos unblocks the ability to fully automate the configuration of your Jenkins. Instead of having a gate keeper that is manually managing Jenkins when needed, the jobs are automatically updated based on github repos, giving developers the ability to manage their builds.
Some of the use cases that can be addressed are:
generate-org-jobs on a periodic schedule to automatically create the new jobs for new repos.generate-jobs-for-org.groovy.generate-org-jobs.Hosted at ticketfly/jenkins-example-job-dsl-for-github-org
Content type
Image
Digest
Size
182.9 MB
Last updated
about 9 years ago
docker pull ticketfly/jenkins-example-job-dsl-for-github-org