November 2016
Jenkins Job DSL
Configuration as Code
November 2016
• Introduction
• Jenkins
• How to create jobs/views
• Job DSL
• Questions
November 2016
Tomas Norre Mikkelsen

• AOE GmbH - June 2013
• DevOps/Automation
• TYPO3.org, Crawler
• Golf, #t3runners
• ...
November 2016
We are the champions
- Team FourSquare
November 2016
I have been running marathons
- but still I consider myself being lazy!
November 2016
What is Jenkins?
November 2016
The leading open source automation server,
Jenkins provides hundreds of plugins to support
building, deployi...
November 2016
• Run Unit tests
• Build docker images
• Build artifacts
• Deploy website/applications
• Publish TER Extensi...
November 2016
Create a Jenkins job
November 2016
<?xml version='1.0' encoding='UTF-8'?>
<project>
<description></description>
<keepDependencies>false</keepDe...
November 2016
Challenges
• Copying jobs
• Adjusting same setting multiple times
• UI can be slow
• Fields hidden under adv...
November 2016
Job DSL
• Domain Specific Language
• Groovy
• Can be extend with configure blocks
November 2016
File structure
November 2016
job('t3ee_groovy') {

steps {

shell('''

#!/bin/sh



echo "Welcome to T3EE16 - Jenkins JobDSL"

''')

}

}...
November 2016
Play ground
November 2016
How to setup Jenkins JobDSL
• install Job DSL plugin
• Seeder job
November 2016
Seeder Job
November 2016
Shared configuration
November 2016
Looping for environments
November 2016
Setting up views
November 2016
How to test your jobs
November 2016
Pros & Cons
• Version Control
• More readable
• Change shared configurations
• Test locally
• Review
• Not a...
November 2016
Best practice
• Start converting few jobs
• All jobs goes to version control
• Trigger seed job on SCM chang...
November 2016
Developers want to write code,
so let them do what they love!
November 2016
Questions?
@tomasnorre tomas.mikkelsen@aoe.com
November 2016
• https://jenkinsci.github.io/job-dsl-plugin/ - Documentation
• http://job-dsl.herokuapp.com/ - Play Ground
...
Upcoming SlideShare
Loading in …5
×

Jenkins JobDSL - Configuration as code

106 views

Published on

Jenkins Job DSL Configuration as Code
Most developers want to write code, they don’t want to click around in GUIs or do manual work. A lot of development teams uses Jenkins for package building, testing and tons of other automated jobs. All of this, of course, to improve the overall quality and simplicity of a project, but also to remove some of the “pain” from the developers.
Most teams configure everything in Jenkins manually and with limited history, versioning and rollback options.
What can be done to help developers focus on developing while benefitting from their daily work in the Jenkins setup at the same time?

Published in: Software
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
106
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Jenkins JobDSL - Configuration as code

  1. 1. November 2016 Jenkins Job DSL Configuration as Code
  2. 2. November 2016 • Introduction • Jenkins • How to create jobs/views • Job DSL • Questions
  3. 3. November 2016 Tomas Norre Mikkelsen
 • AOE GmbH - June 2013 • DevOps/Automation • TYPO3.org, Crawler • Golf, #t3runners • @tomasnorre
  4. 4. November 2016 We are the champions - Team FourSquare
  5. 5. November 2016 I have been running marathons - but still I consider myself being lazy!
  6. 6. November 2016 What is Jenkins?
  7. 7. November 2016 The leading open source automation server, Jenkins provides hundreds of plugins to support building, deploying and automating any project. - https://jenkins.io/
  8. 8. November 2016 • Run Unit tests • Build docker images • Build artifacts • Deploy website/applications • Publish TER Extensions on Git-tag • etc. What can we use Jenkins for
  9. 9. November 2016 Create a Jenkins job
  10. 10. November 2016 <?xml version='1.0' encoding='UTF-8'?> <project> <description></description> <keepDependencies>false</keepDependencies> <properties> <hudson.plugins.buildblocker.BuildBlockerProperty plugin="build-blocker-plugin@1.7.3"> <useBuildBlocker>false</useBuildBlocker> <blockLevel>GLOBAL</blockLevel> <scanQueueFor>DISABLED</scanQueueFor> <blockingJobs></blockingJobs> </hudson.plugins.buildblocker.BuildBlockerProperty> <com.sonyericsson.rebuild.RebuildSettings plugin="rebuild@1.25"> <autoRebuild>false</autoRebuild> <rebuildDisabled>false</rebuildDisabled> </com.sonyericsson.rebuild.RebuildSettings> </properties> <scm class="hudson.scm.NullSCM"/> <canRoam>true</canRoam> <disabled>false</disabled> <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> <triggers/> <concurrentBuild>false</concurrentBuild> <builders> <hudson.tasks.Shell> <command>#!/bin/sh echo &quot;Welcome to T3EE16 - Jenkins JobDSL&quot;</command> </hudson.tasks.Shell> </builders> <publishers/> <buildWrappers/> </project> Every configuration is XML
  11. 11. November 2016 Challenges • Copying jobs • Adjusting same setting multiple times • UI can be slow • Fields hidden under advanced button
  12. 12. November 2016 Job DSL • Domain Specific Language • Groovy • Can be extend with configure blocks
  13. 13. November 2016 File structure
  14. 14. November 2016 job('t3ee_groovy') {
 steps {
 shell('''
 #!/bin/sh
 
 echo "Welcome to T3EE16 - Jenkins JobDSL"
 ''')
 }
 } Groove Job
  15. 15. November 2016 Play ground
  16. 16. November 2016 How to setup Jenkins JobDSL • install Job DSL plugin • Seeder job
  17. 17. November 2016 Seeder Job
  18. 18. November 2016 Shared configuration
  19. 19. November 2016 Looping for environments
  20. 20. November 2016 Setting up views
  21. 21. November 2016 How to test your jobs
  22. 22. November 2016 Pros & Cons • Version Control • More readable • Change shared configurations • Test locally • Review • Not all plugins are supported • Learning curve
  23. 23. November 2016 Best practice • Start converting few jobs • All jobs goes to version control • Trigger seed job on SCM changes • Don’t commit credentials • Think about design, refactor, streamline etc. it’s code treat it like code.
  24. 24. November 2016 Developers want to write code, so let them do what they love!
  25. 25. November 2016 Questions? @tomasnorre tomas.mikkelsen@aoe.com
  26. 26. November 2016 • https://jenkinsci.github.io/job-dsl-plugin/ - Documentation • http://job-dsl.herokuapp.com/ - Play Ground • http://www.groovy-lang.org/ - Groove Website • https://github.com/tomasnorre/t3ee16_jenkins - Example Repository
 Links

×