1.1 Create Kubernetes ReplicationController for Jenkins (master) container using jenkins-rc.yaml:
kubectl create -f kube/jenkins-rc.yaml
1.2 Create Kubernetes service for Jenkins using jenkins-service.yaml
NOTE: At this stage in the command output you should notice the TCP ports which are assigned for Jenkins UI and discovery services:
kubectl create -f kube/jenkins-service.yaml
NOTE: if you want to attach build slave servers through JNLP (Java Web Start): make sure you map the port: 50000
- which will be used when you connect a slave agent. If you are only using ssh-slaves, then you do NOT need to put port 50000 mapping.
kubectl logs jenkins
Open web browser and type Kubernetes node IP address and TCP port noticed at 1.2 stage. You might see Jenkinse welcome page as below:
Go to "Manage Jenkins" - "Plugin Manager". Select plugins you want to update and complete updating with Jenkins restart.
Click "create new jobs" link in welcome screen, choose "Freestyle project" and name it somehow
Choose "Use the provided DSL script" and paste file dsl-seed-job-simple.goovy content to the form:
NOTE: In the seed job we creating regular job "DSL-Tutorial-1" which clones git repository from giturl
on the described in triggers
section schedule and accomplish task described in steps
(just printing "Step N1", but you may define any command or script).
Possible options are documented at Jenkins Job DSL API
resource and this manual is quite comprehensive.
You'll get job creation result page with the generated job name in the "Generated item" section%
Click "Build Now" and check console output - it should look like this:
Go "Back to Project" then "Back to Dashboard" and checkout generated job "DSL-Tutorial-1-Test"
The "DSL-Tutorial-1" job has been generated from our DSL seed job "job-dsl-1" and should run as scheduled in triggers
section of seed job or you may start it manually by pressing on "Build Now" option.
Results can be observed in the Console Output
and should contain Finished: SUCCESS line:
Create new seed DSL job and paste dsl-seed-job-loop.groovy content to "Use the provided DSL script" form. In this job we manage Jenkins to create several jobs with the index number in the name. Now if you build it you'll get a number of generated jobs in the Dashboard:
And all of those jobs will run with parameters, schedules, credentials, commands or other handles defined in the loop.