Jenkins The Definitive Guide

jenkins-the-definitive-guide

jenkins-the-definitive-guide

jenkins-the-definitive-guide

jenkins-the-definitive-guide

Jenkins-the-definitive-guide

User Manual: Pdf

Open the PDF directly: View PDF PDF.
Page Count: 417 [warning: Documents this large are best viewed by clicking the View PDF Link!]

John Ferguson Smart
Hudson
Continuous Integration for the Masses
Creative Commons Edition
Jenkins
The Definitive Guide
Copyright .................................................................................................................... xix
Foreword ..................................................................................................................... xxi
Preface ...................................................................................................................... xxiii
1. Audience ....................................................................................................... xxiii
2. Book Layout .................................................................................................. xxiii
3. Jenkins or Hudson? ......................................................................................... xxiii
4. Font Conventions ............................................................................................ xxiv
5. Command-Line Conventions ............................................................................. xxiv
6. Contributors .................................................................................................... xxv
7. The Review Team ........................................................................................... xxvi
8. Book Sponsors ................................................................................................ xxvi
8.1. Wakaleo Consulting .............................................................................. xxvi
8.2. CloudBees .......................................................................................... xxvii
8.3. Odd-e ................................................................................................ xxvii
9. Using Code Examples .................................................................................... xxviii
10. Safari® Books Online ................................................................................... xxviii
11. How to Contact Us ........................................................................................ xxix
12. Acknowledgments .......................................................................................... xxix
1. Introducing Jenkins ...................................................................................................... 1
1.1. Introduction ..................................................................................................... 1
1.2. Continuous Integration Fundamentals .................................................................... 1
1.3. Introducing Jenkins (née Hudson) ........................................................................ 2
1.4. From Hudson to JenkinsA Short History ............................................................ 3
1.5. Should I Use Jenkins or Hudson? ......................................................................... 4
1.6. Introducing Continuous Integration into Your Organization ....................................... 5
1.6.1. Phase 1No Build Server ....................................................................... 5
1.6.2. Phase 2Nightly Builds .......................................................................... 5
1.6.3. Phase 3—Nightly Builds and Basic Automated Tests ..................................... 5
1.6.4. Phase 4Enter the Metrics ...................................................................... 6
1.6.5. Phase 5—Getting More Serious About Testing ............................................. 6
1.6.6. Phase 6—Automated Acceptance Tests and More Automated Deployment ......... 6
1.6.7. Phase 7Continuous Deployment ............................................................. 6
1.7. Where to Now? ................................................................................................ 7
2. Your First Steps with Jenkins ........................................................................................ 9
2.1. Introduction ..................................................................................................... 9
2.2. Preparing Your Environment ............................................................................... 9
2.2.1. Installing Java ...................................................................................... 10
2.2.2. Installing Git ........................................................................................ 11
2.2.3. Setting Up a GitHub Account .................................................................. 11
2.2.4. Configuring SSH Keys ........................................................................... 12
2.2.5. Forking the Sample Repository ................................................................ 12
2.3. Starting Up Jenkins .......................................................................................... 14
2.4. Configuring the Tools ...................................................................................... 17
iv
2.4.1. Configuring Your Maven Setup ............................................................... 18
2.4.2. Configuring the JDK ............................................................................. 19
2.4.3. Notification .......................................................................................... 20
2.4.4. Setting Up Git ...................................................................................... 20
2.5. Your First Jenkins Build Job ............................................................................. 21
2.6. Your First Build Job in Action .......................................................................... 26
2.7. More ReportingDisplaying Javadocs ................................................................ 33
2.8. Adding Code Coverage and Other Metrics ........................................................... 35
2.9. Conclusion ..................................................................................................... 41
3. Installing Jenkins ....................................................................................................... 43
3.1. Introduction .................................................................................................... 43
3.2. Downloading and Installing Jenkins .................................................................... 43
3.3. Preparing a Build Server for Jenkins ................................................................... 46
3.4. The Jenkins Home Directory ............................................................................. 47
3.5. Installing Jenkins on Debian or Ubuntu ............................................................... 48
3.6. Installing Jenkins on Redhat, Fedora, or CentOS ................................................... 49
3.7. Installing Jenkins on SUSE or OpenSUSE ........................................................... 50
3.8. Running Jenkins as a Stand-Alone Application ..................................................... 51
3.9. Running Jenkins Behind an Apache Server .......................................................... 54
3.10. Running Jenkins on an Application Server .......................................................... 55
3.11. Memory Considerations .................................................................................. 56
3.12. Installing Jenkins as a Windows Service ............................................................ 56
3.13. Whats in the Jenkins Home Directory ............................................................... 60
3.14. Backing Up Your Jenkins Data ........................................................................ 64
3.15. Upgrading Your Jenkins Installation .................................................................. 64
3.16. Conclusion ................................................................................................... 65
4. Configuring Your Jenkins Server .................................................................................. 67
4.1. Introduction .................................................................................................... 67
4.2. The Configuration Dashboard—The Manage Jenkins Screen .................................... 67
4.3. Configuring the System Environment .................................................................. 70
4.4. Configuring Global Properties ............................................................................ 71
4.5. Configuring Your JDKs .................................................................................... 72
4.6. Configuring Your Build Tools ........................................................................... 74
4.6.1. Maven ................................................................................................. 74
4.6.2. Ant ..................................................................................................... 76
4.6.3. Shell-Scripting Language ........................................................................ 77
4.7. Configuring Your Version Control Tools ............................................................. 77
4.7.1. Configuring Subversion .......................................................................... 77
4.7.2. Configuring CVS .................................................................................. 77
4.8. Configuring the Mail Server .............................................................................. 78
4.9. Configuring a Proxy ........................................................................................ 79
4.10. Conclusion ................................................................................................... 80
5. Setting Up Your Build Jobs ......................................................................................... 81
v
5.1. Introduction .................................................................................................... 81
5.2. Jenkins Build Jobs ........................................................................................... 81
5.3. Creating a Freestyle Build Job ........................................................................... 82
5.3.1. General Options .................................................................................... 82
5.3.2. Advanced Project Options ...................................................................... 84
5.4. Configuring Source Code Management ................................................................ 85
5.4.1. Working with Subversion ....................................................................... 86
5.4.2. Working with Git .................................................................................. 88
5.5. Build Triggers ............................................................................................... 100
5.5.1. Triggering a Build Job Once Another Build Job Has Finished ...................... 101
5.5.2. Scheduled Build Jobs ........................................................................... 101
5.5.3. Polling the SCM ................................................................................. 102
5.5.4. Triggering Builds Remotely .................................................................. 103
5.5.5. Manual Build Jobs ............................................................................... 105
5.6. Build Steps ................................................................................................... 105
5.6.1. Maven Build Steps .............................................................................. 105
5.6.2. Ant Build Steps .................................................................................. 107
5.6.3. Executing a Shell or Windows Batch Command ........................................ 107
5.6.4. Using Jenkins Environment Variables in Your Builds ................................. 109
5.6.5. Running Groovy Scripts ....................................................................... 111
5.6.6. Building Projects in Other Languages ..................................................... 113
5.7. Post-Build Actions ......................................................................................... 113
5.7.1. Reporting on Test Results ..................................................................... 113
5.7.2. Archiving Build Results ....................................................................... 114
5.7.3. Notifications ....................................................................................... 117
5.7.4. Building Other Projects ........................................................................ 118
5.8. Running Your New Build Job .......................................................................... 118
5.9. Working with Maven Build Jobs ...................................................................... 118
5.9.1. Building Whenever a SNAPSHOT Dependency Is Built .............................. 119
5.9.2. Configuring the Maven Build ................................................................ 120
5.9.3. Post-Build Actions ............................................................................... 121
5.9.4. Deploying to an Enterprise Repository Manager ........................................ 122
5.9.5. Deploying to Commercial Enterprise Repository Managers .......................... 125
5.9.6. Managing Modules .............................................................................. 126
5.9.7. Extra Build Steps in Your Maven Build Jobs ............................................ 127
5.10. Using Jenkins with Other Languages ............................................................... 127
5.10.1. Building Projects with Grails ............................................................... 127
5.10.2. Building Projects with Gradle .............................................................. 129
5.10.3. Building Projects with Visual Studio MSBuild ........................................ 132
5.10.4. Building Projects with NAnt ................................................................ 133
5.10.5. Building Projects with Ruby and Ruby on Rails ....................................... 134
5.11. Conclusion .................................................................................................. 136
6. Automated Testing ................................................................................................... 137
vi
6.1. Introduction .................................................................................................. 137
6.2. Automating Your Unit and Integration Tests ....................................................... 138
6.3. Configuring Test Reports in Jenkins .................................................................. 139
6.4. Displaying Test Results .................................................................................. 141
6.5. Ignoring Tests ............................................................................................... 144
6.6. Code Coverage .............................................................................................. 146
6.6.1. Measuring Code Coverage with Cobertura ............................................... 147
6.6.2. Measuring Code Coverage with Clover .................................................... 156
6.7. Automated Acceptance Tests ........................................................................... 157
6.8. Automated Performance Tests with JMeter ......................................................... 160
6.9. Help! My Tests Are Too Slow! ........................................................................ 168
6.9.1. Add More Hardware ............................................................................ 168
6.9.2. Run Fewer Integration/Functional Tests ................................................... 169
6.9.3. Run Your Tests in Parallel .................................................................... 169
6.10. Conclusion .................................................................................................. 170
7. Securing Jenkins ...................................................................................................... 171
7.1. Introduction .................................................................................................. 171
7.2. Activating Security in Jenkins .......................................................................... 171
7.3. Simple Security in Jenkins .............................................................................. 172
7.4. Security RealmsIdentifying Jenkins Users ....................................................... 173
7.4.1. Using Jenkins’s Built-in User Database ................................................... 173
7.4.2. Using an LDAP Repository ................................................................... 176
7.4.3. Using Microsoft Active Directory ........................................................... 178
7.4.4. Using Unix Users and Groups ............................................................... 179
7.4.5. Delegating to the Servlet Container ......................................................... 179
7.4.6. Using Atlassian Crowd ......................................................................... 180
7.4.7. Integrating with Other Systems .............................................................. 181
7.5. AuthorizationWho Can Do What ................................................................... 183
7.5.1. Matrix-based Security .......................................................................... 183
7.5.2. Project-based Security .......................................................................... 187
7.5.3. Role-based Security ............................................................................. 189
7.6. AuditingKeeping Track of User Actions ......................................................... 191
7.7. Conclusion ................................................................................................... 194
8. Notification ............................................................................................................. 197
8.1. Introduction .................................................................................................. 197
8.2. Email Notification .......................................................................................... 197
8.3. More Advanced Email Notification ................................................................... 198
8.4. Claiming Builds ............................................................................................ 202
8.5. RSS Feeds .................................................................................................... 203
8.6. Build Radiators ............................................................................................. 204
8.7. Instant Messaging .......................................................................................... 206
8.7.1. IM Notification with Jabber .................................................................. 206
8.7.2. IM Notification using IRC .................................................................... 210
vii
8.8. IRC Notification ............................................................................................ 211
8.9. Desktop Notifiers ........................................................................................... 214
8.10. Notification via Notifo .................................................................................. 217
8.11. Mobile Notification ...................................................................................... 219
8.12. SMS Notification ......................................................................................... 220
8.13. Making Noise .............................................................................................. 222
8.14. Extreme Feedback Devices ............................................................................ 224
8.15. Conclusion .................................................................................................. 226
9. Code Quality ........................................................................................................... 227
9.1. Introduction .................................................................................................. 227
9.2. Code Quality in Your Build Process .................................................................. 228
9.3. Popular Java and Groovy Code Quality Analysis Tools ......................................... 229
9.3.1. Checkstyle ......................................................................................... 229
9.3.2. PMD/CPD .......................................................................................... 232
9.3.3. FindBugs ........................................................................................... 236
9.3.4. CodeNarc ........................................................................................... 238
9.4. Reporting on Code Quality Issues with the Violations Plugin ................................. 239
9.4.1. Working with Freestyle Build Jobs ......................................................... 240
9.4.2. Working with Maven Build Jobs ............................................................ 243
9.5. Using the Checkstyle, PMD, and FindBugs Reports ............................................. 245
9.6. Reporting on Code Complexity ........................................................................ 248
9.7. Reporting on Open Tasks ................................................................................ 249
9.8. Integrating with Sonar .................................................................................... 251
9.9. Conclusion ................................................................................................... 255
10. Advanced Builds .................................................................................................... 257
10.1. Introduction ................................................................................................. 257
10.2. Parameterized Build Jobs ............................................................................... 257
10.2.1. Creating a Parameterized Build Job ....................................................... 257
10.2.2. Adapting Your Builds to Work with Parameterized Build Scripts ................. 259
10.2.3. More Advanced Parameter Types ......................................................... 261
10.2.4. Building from a Subversion Tag ........................................................... 262
10.2.5. Building from a Git Tag ..................................................................... 263
10.2.6. Starting a Parameterized Build Job Remotely .......................................... 264
10.2.7. Parameterized Build Job History ........................................................... 265
10.3. Parameterized Triggers .................................................................................. 265
10.4. Multiconfiguration Build Jobs ........................................................................ 268
10.4.1. Setting Up a Multiconfiguration Build ................................................... 268
10.4.2. Configuring a Slave Axis .................................................................... 269
10.4.3. Configuring a JDK Axis ..................................................................... 270
10.4.4. Custom Axis ..................................................................................... 271
10.4.5. Running a Multiconfiguration Build ...................................................... 271
10.5. Generating Your Maven Build Jobs Automatically ............................................. 274
10.5.1. Configuring a Job .............................................................................. 275
viii
10.5.2. Reusing Job Configuration with Inheritance ............................................ 277
10.5.3. Plugin Support .................................................................................. 278
10.5.4. Freestyle Jobs ................................................................................... 281
10.6. Coordinating Your Builds .............................................................................. 281
10.6.1. Parallel Builds in Jenkins .................................................................... 282
10.6.2. Dependency Graphs ........................................................................... 282
10.6.3. Joins ................................................................................................ 283
10.6.4. Locks and Latches ............................................................................. 284
10.7. Build Pipelines and Promotions ...................................................................... 285
10.7.1. Managing Maven Releases with the M2Release Plugin .............................. 286
10.7.2. Copying Artifacts .............................................................................. 289
10.7.3. Build Promotions ............................................................................... 292
10.7.4. Aggregating Test Results .................................................................... 300
10.7.5. Build Pipelines .................................................................................. 301
10.8. Conclusion .................................................................................................. 304
11. Distributed Builds ................................................................................................... 305
11.1. Introduction ................................................................................................. 305
11.2. The Jenkins Distributed Build Architecture ....................................................... 305
11.3. Master/Slave Strategies in Jenkins ................................................................... 306
11.3.1. The Master Starts the Slave Agent Using SSH ......................................... 306
11.3.2. Starting the Slave Agent Manually Using Java Web Start .......................... 310
11.3.3. Installing a Jenkins Slave as a Windows Service ...................................... 313
11.3.4. Starting the Slave Node in Headless Mode ............................................. 314
11.3.5. Starting a Windows Slave as a Remote Service ........................................ 315
11.4. Associating a Build Job with a Slave or Group of Slaves ..................................... 315
11.5. Node Monitoring .......................................................................................... 317
11.6. Cloud Computing ......................................................................................... 318
11.6.1. Using Amazon EC2 ........................................................................... 318
11.7. Using the CloudBees DEV@cloud Service ....................................................... 322
11.8. Conclusion .................................................................................................. 323
12. Automated Deployment and Continuous Delivery ......................................................... 325
12.1. Introduction ................................................................................................. 325
12.2. Implementing Automated and Continuous Deployment ........................................ 326
12.2.1. The Deployment Script ....................................................................... 326
12.2.2. Database Updates .............................................................................. 326
12.2.3. Smoke Tests ..................................................................................... 329
12.2.4. Rolling Back Changes ........................................................................ 329
12.3. Deploying to an Application Server ................................................................. 330
12.3.1. Deploying a Java Application .............................................................. 330
12.3.2. Deploying Scripting-based Applications Like Ruby and PHP ...................... 339
12.4. Conclusion .................................................................................................. 342
13. Maintaining Jenkins ................................................................................................ 345
13.1. Introduction ................................................................................................. 345
ix
13.2. Monitoring Disk Space .................................................................................. 345
13.2.1. Using the Disk Usage Plugin ............................................................... 346
13.2.2. Disk Usage and the Jenkins Maven Project Type ..................................... 348
13.3. Monitoring the Server Load ........................................................................... 349
13.4. Backing Up Your Configuration ..................................................................... 351
13.4.1. Fundamentals of Jenkins Backups ......................................................... 351
13.4.2. Using the Backup Plugin ..................................................................... 353
13.4.3. More Lightweight Automated Backups .................................................. 354
13.5. Archiving Build Jobs .................................................................................... 355
13.6. Migrating Build Jobs .................................................................................... 356
13.7. Conclusion .................................................................................................. 359
A. Automating Your Unit and Integration Tests ................................................................ 361
A.1. Automating Your Tests with Maven ................................................................. 361
A.2. Automating Your Tests with Ant ..................................................................... 366
Index ......................................................................................................................... 371
List of Figures
2.1. Installing Java ......................................................................................................... 10
2.2. Signing up for a GitHub account ................................................................................ 12
2.3. Forking the sample code repository ............................................................................ 13
2.4. Running Jenkins using Java Web Start from the book’s website ....................................... 14
2.5. Java Web Start will download and run the latest version of Jenkins ................................... 15
2.6. Java Web Start running Jenkins ................................................................................. 15
2.7. The Jenkins start page .............................................................................................. 16
2.8. The Manage Jenkins screen ....................................................................................... 17
2.9. The Configure Jenkins screen .................................................................................... 18
2.10. Configuring a Maven installation .............................................................................. 19
2.11. Configuring a JDK installation ................................................................................. 20
2.12. Managing plugins in Jenkins .................................................................................... 21
2.13. Installing the Git plugin .......................................................................................... 21
2.14. Setting up your first build job in Jenkins .................................................................... 23
2.15. Telling Jenkins where to find the source code ............................................................. 24
2.16. Scheduling the build jobs ........................................................................................ 25
2.17. Adding a build step ................................................................................................ 25
2.18. Configuring JUnit test reports and artifact archiving ..................................................... 26
2.19. Your first build job running ..................................................................................... 27
2.20. The Jenkins dashboard ............................................................................................ 27
2.21. A failed build ....................................................................................................... 30
2.22. The list of all the broken tests .................................................................................. 31
2.23. Details about a failed test ........................................................................................ 31
2.24. Now the build is back to normal .............................................................................. 33
2.25. Adding a new build step and report to generate Javadoc ................................................ 34
2.26. Jenkins will add a Javadoc link to your build results ..................................................... 35
2.27. Jenkins has a large range of plugins available ............................................................. 36
2.28. Adding another Maven goal to generating test coverage metrics ...................................... 37
2.29. Configuring the test coverage metrics in Jenkins .......................................................... 38
2.30. Jenkins displays code coverage metrics on the build home page ...................................... 39
2.31. Jenkins lets you display code coverage metrics for packages and classes ........................... 40
2.32. Jenkins also displays a graph of code coverage over time .............................................. 41
3.1. You can download the Jenkins binaries from the Jenkins website ...................................... 44
3.2. Jenkins setup wizard in Windows ............................................................................... 45
3.3. The Jenkins start page .............................................................................................. 46
3.4. Starting Jenkins using Java Web Start ......................................................................... 57
3.5. Installing Jenkins as a Windows service ...................................................................... 58
3.6. Configuring the Jenkins Windows Service ................................................................... 59
3.7. The Jenkins home directory ....................................................................................... 61
3.8. The Jenkins jobs directory ........................................................................................ 62
xii
3.9. The builds directory ................................................................................................. 63
3.10. Upgrading Jenkins from the web interface .................................................................. 65
4.1. You configure your Jenkins installation in the Manage Jenkins screen ............................... 68
4.2. System configuration in Jenkins ................................................................................. 70
4.3. Configuring environment variables in Jenkins ............................................................... 72
4.4. Using a configured environment variable ..................................................................... 72
4.5. JDK configuration in Jenkins ..................................................................................... 73
4.6. Installing a JDK automatically ................................................................................... 74
4.7. Configuring Maven in Jenkins ................................................................................... 75
4.8. Configuring system-wide MVN_OPTS ........................................................................ 76
4.9. Configuring Ant in Jenkins ....................................................................................... 77
4.10. Configuring an email server in Jenkins ...................................................................... 78
4.11. Configuring an email server in Jenkins to use a Google Apps domain .............................. 79
4.12. Configuring Jenkins to use a proxy ........................................................................... 80
5.1. Jenkins supports four main types of build jobs .............................................................. 82
5.2. Creating a new build job .......................................................................................... 83
5.3. Keeping a build job forever ....................................................................................... 83
5.4. To display the Advanced Options, you need to click on the Advanced button ...................... 84
5.5. The “Block build when upstream project is building” option is useful when a single commit
can affect several related projects ..................................................................................... 85
5.6. Jenkins provides built-in support for Subversion ............................................................ 86
5.7. Source code browser showing what code changes caused a build ...................................... 87
5.8. System-wide configuration of the Git plugin ................................................................. 89
5.9. Entering a Git repo URL .......................................................................................... 91
5.10. Advanced configuration of a Git repo URL ................................................................ 91
5.11. Advanced configuration of the Git branches to build .................................................... 92
5.12. Branches and regions ............................................................................................. 93
5.13. Choosing strategy .................................................................................................. 95
5.14. Git executable global setup ...................................................................................... 95
5.15. Repository browser ................................................................................................ 96
5.16. Polling log ............................................................................................................ 96
5.17. Results of Git polling ............................................................................................. 97
5.18. Gerrit Trigger ........................................................................................................ 97
5.19. Git Publisher ......................................................................................................... 98
5.20. Merge results ........................................................................................................ 99
5.21. GitHub repository browser ..................................................................................... 100
5.22. GitHub repository browser ..................................................................................... 100
5.23. There are many ways that you can configure Jenkins to start a build job .......................... 100
5.24. Triggering another build job even if the current one is unstable ..................................... 101
5.25. Triggering a build via a URL using a token .............................................................. 104
5.26. Adding a build step to a freestyle build job ............................................................... 106
5.27. Configuring an Ant build step ................................................................................ 107
5.28. Configuring an Execute Shell step ........................................................................... 108
xiii
5.29. Adding a Groovy installation to Jenkins ................................................................... 111
5.30. Running Groovy commands as part of a build job ...................................................... 112
5.31. Running Groovy scripts as part of a build job ............................................................ 113
5.32. Reporting on test results ........................................................................................ 114
5.33. Configuring build artifacts ..................................................................................... 114
5.34. Build artifacts are displayed on the build results page and on the build job home page ........ 115
5.35. Archiving source code and a binary package ............................................................. 117
5.36. Email notification ................................................................................................. 118
5.37. Creating a new Maven build job ............................................................................. 119
5.38. Specifying the Maven goals ................................................................................... 120
5.39. Maven build jobsadvanced options ....................................................................... 120
5.40. Deploying artifacts to a Maven repository ................................................................. 122
5.41. After deployment the artifact should be available on your Enterprise Repository Manager
.................................................................................................................................. 123
5.42. Redeploying an artifact ......................................................................................... 124
5.43. Deploying to Artifactory from Jenkins ..................................................................... 124
5.44. Jenkins displays a link to the corresponding Artifactory repository ................................. 125
5.45. Viewing the deployed artifact in Artifactory .............................................................. 125
5.46. Viewing the deployed artifact and the corresponding Jenkins build in Artifactory .............. 126
5.47. Managing modules in a Maven build job .................................................................. 126
5.48. Configuring extra Maven build steps ....................................................................... 127
5.49. Adding a Grails installation to Jenkins ..................................................................... 128
5.50. Configuring a Grails build step ............................................................................... 129
5.51. Configuring the Gradle plugin ................................................................................ 130
5.52. Setting up a Gradle build job ................................................................................. 132
5.53. Incremental Gradle job .......................................................................................... 132
5.54. Configuring .NET build tools in Jenkins ................................................................... 133
5.55. A build step using MSBuild ................................................................................... 133
5.56. A build step using NAnt ....................................................................................... 134
5.57. A build step using Rake ........................................................................................ 135
5.58. Publishing code quality metrics for Ruby and Rails .................................................... 136
6.1. You configure your Jenkins installation in the Manage Jenkins screen .............................. 139
6.2. Configuring Maven test reports in a freestyle project .................................................... 140
6.3. Installing the xUnit plugin ....................................................................................... 140
6.4. Publishing xUnit test results .................................................................................... 141
6.5. Jenkins displays test result trends on the project home page ........................................... 142
6.6. Jenkins displays a summary of the test results ............................................................. 142
6.7. The details of a test failure ...................................................................................... 143
6.8. Build time trends can give you a good indicator of how fast your tests are running .............. 144
6.9. Jenkins also lets you see how long your tests take to run ............................................... 145
6.10. Jenkins displays skipped tests as yellow ................................................................... 146
6.11. Installing the Cobertura plugin ............................................................................... 152
6.12. Your code coverage metrics build needs to generate the coverage data ............................ 152
xiv
6.13. Configuring the test coverage metrics in Jenkins ........................................................ 153
6.14. Test coverage results contribute to the project status on the dashboard ............................ 154
6.15. Configuring the test coverage metrics in Jenkins ........................................................ 155
6.16. Displaying code coverage metrics ........................................................................... 155
6.17. Configuring Clover reporting in Jenkins ................................................................... 157
6.18. Clover code coverage trends .................................................................................. 157
6.19. Using business-focused, behavior-driven naming conventions for JUnit tests .................... 158
6.20. Installing the HTML Publisher plugin ...................................................................... 159
6.21. Publishing HTML reports ...................................................................................... 159
6.22. Jenkins displays a special link on the build job home page for your report ....................... 159
6.23. The DocLinks plugin lets you archive both HTML and non-HTML artifacts .................... 160
6.24. Preparing a performance test script in JMeter ............................................................ 162
6.25. Preparing a performance test script in JMeter ............................................................ 164
6.26. Setting up the performance build to run every night at midnight .................................... 165
6.27. Performance tests can require large amounts of memory .............................................. 165
6.28. Configuring the Performance plugin in your build job ................................................. 166
6.29. The Jenkins Performance plugin keeps track of response time and errors ......................... 166
6.30. You can also view performance results per request ..................................................... 168
7.1. Enabling security in Jenkins .................................................................................... 172
7.2. The Jenkins Sign up page ....................................................................................... 173
7.3. The list of users known to Jenkins ............................................................................ 174
7.4. Displaying the builds that a user participates in ........................................................... 174
7.5. Creating a new user account by signing up ................................................................. 175
7.6. Synchronizing email addresses ................................................................................. 175
7.7. You can also manage Jenkins users from the Jenkins configuration page ........................... 176
7.8. The Jenkins user database ....................................................................................... 176
7.9. Configuring LDAP in Jenkins .................................................................................. 177
7.10. Using LDAP Groups in Jenkins .............................................................................. 178
7.11. Selecting the security realm ................................................................................... 179
7.12. Using Atlassian Crowd as the Jenkins Security Realm ................................................. 180
7.13. Using Atlassian Crowd as the Jenkins Security Realm ................................................. 181
7.14. Using Atlassian Crowd groups in Jenkins ................................................................. 181
7.15. Using custom scripts to handle authentication ............................................................ 182
7.16. Matrix-based security configuration ......................................................................... 184
7.17. Setting up an administrator .................................................................................... 184
7.18. Setting up other users ........................................................................................... 184
7.19. Project-based security ........................................................................................... 187
7.20. Configuring project-based security .......................................................................... 188
7.21. Viewing a project ................................................................................................. 188
7.22. Setting up Extended Read Permissions ..................................................................... 189
7.23. Setting up Role-based security ................................................................................ 189
7.24. The Manage Roles configuration menu .................................................................... 190
7.25. Managing global roles ........................................................................................... 190
xv
7.26. Managing project roles .......................................................................................... 191
7.27. Assigning roles to users ........................................................................................ 191
7.28. Configuring the Audit Trail plugin .......................................................................... 192
7.29. Setting up Job Configuration History ....................................................................... 193
7.30. Viewing Job Configuration History ......................................................................... 194
7.31. Viewing differences in Job Configuration History ...................................................... 194
8.1. Configuring email notification .................................................................................. 197
8.2. Configuring advanced email notification .................................................................... 199
8.3. Configuring email notification triggers ....................................................................... 201
8.4. Customized notification message .............................................................................. 202
8.5. Claiming a failed build ........................................................................................... 203
8.6. RSS Feeds in Jenkins ............................................................................................. 204
8.7. Creating a build radiator view .................................................................................. 205
8.8. Displaying a build radiator view ............................................................................... 206
8.9. Installing the Jenkins IM plugins .............................................................................. 207
8.10. Jenkins needs its own dedicated IM user account ....................................................... 207
8.11. Setting up basic Jabber notification in Jenkins ........................................................... 208
8.12. Advanced Jabber configuration ............................................................................... 208
8.13. Jenkins Jabber messages in action ........................................................................... 210
8.14. Install the Jenkins IRC plugins ............................................................................... 211
8.15. Advanced IRC notification configuration .................................................................. 212
8.16. Advanced build job IRC notification configuration ..................................................... 213
8.17. IRC notification messages in action ......................................................................... 214
8.18. Jenkins notifications in Eclipse ............................................................................... 215
8.19. Launching the Jenkins Tray Application ................................................................... 216
8.20. Running the Jenkins Tray Application ...................................................................... 216
8.21. Creating a Notifo service for your Jenkins instance ..................................................... 218
8.22. Configuring Notifo notifications in your Jenkins build job ........................................... 218
8.23. Receiving a Notifo notification on an iPhone ............................................................. 219
8.24. Using the Hudson Helper iPhone app ....................................................................... 220
8.25. Sending SMS notifications via an SMS Gateway Service ............................................. 221
8.26. Receiving notification via SMS .............................................................................. 222
8.27. Configuring Jenkins Sounds rules in a build job ......................................................... 223
8.28. Configuring Jenkins Sounds ................................................................................... 223
8.29. Configuring Jenkins Speaks ................................................................................... 224
8.30. A Nabaztag ......................................................................................................... 225
8.31. Configuring your Nabaztag .................................................................................... 226
9.1. It is easy to configure Checkstyle rules in Eclipse ........................................................ 230
9.2. Configuring PMD rules in Eclipse ............................................................................ 233
9.3. Generating code quality reports in a Maven build ........................................................ 239
9.4. Configuring the violations plugin for a Freestyle project ................................................ 240
9.5. Violations over time ............................................................................................... 241
9.6. Violations for a given build ..................................................................................... 241
xvi
9.7. Configuring the violations plugin for a Freestyle project ................................................ 243
9.8. Configuring the violations plugin for a Maven project .................................................. 243
9.9. Jenkins Maven build jobs understand Maven multimodule structures ............................... 244
9.10. Activating the Violations plugin for an individual module ............................................ 245
9.11. Installing the Checkstyle and Static Analysis Utilities plugins ....................................... 246
9.12. Configuring the Checkstyle plugin .......................................................................... 247
9.13. Displaying Checkstyle trends ................................................................................. 247
9.14. A coverage/complexity scatter plot .......................................................................... 248
9.15. You can click on any point in the graph to investigate further ....................................... 249
9.16. Configuring the Task Scanner plugin is straightforward ............................................... 250
9.17. The Open Tasks Trend graph ................................................................................. 250
9.18. Code quality reporting by Sonar ............................................................................. 251
9.19. Jenkins and Sonar ................................................................................................ 252
9.20. Configuring Sonar in Jenkins ................................................................................. 253
9.21. Configuring Sonar in a build job ............................................................................. 254
9.22. Scheduling Sonar builds ........................................................................................ 254
10.1. Creating a parameterized build job .......................................................................... 258
10.2. Adding a parameter to the build job ........................................................................ 258
10.3. Adding a parameter to the build job ........................................................................ 259
10.4. Demonstrating a build parameter ............................................................................. 259
10.5. Adding a parameter to a Maven build job ................................................................. 260
10.6. Many different types of parameters are available ........................................................ 261
10.7. Configuring a Choice parameter .............................................................................. 261
10.8. Configuring a Run parameter ................................................................................. 262
10.9. Configuring a File parameter .................................................................................. 262
10.10. Adding a parameter to build from a Subversion tag ................................................... 263
10.11. Building from a Subversion tag ............................................................................. 263
10.12. Configuring a parameter for a Git tag ..................................................................... 264
10.13. Building from a Git tag ....................................................................................... 264
10.14. Jenkins stores what parameter values where used for each build .................................. 265
10.15. Jenkins stores what parameter values where used for each build .................................. 266
10.16. Adding a parameterized trigger to a build job .......................................................... 266
10.17. The build job you trigger must also be a parameterized build job ................................. 267
10.18. Passing a predefined parameter to a parameterized build job ....................................... 268
10.19. Creating a multiconfiguration build job ................................................................... 269
10.20. Adding an axis to a multiconfiguration build ........................................................... 269
10.21. Defining an axis of slave nodes ............................................................................ 270
10.22. Defining an axis of JDK versions .......................................................................... 270
10.23. Defining a user-defined axis ................................................................................. 271
10.24. Multiconfiguration build results ............................................................................. 272
10.25. Setting up a combination filter .............................................................................. 273
10.26. Build results using a combination filter ................................................................... 274
10.27. A job generated by the Maven Jenkins plugin .......................................................... 276
xvii
10.28. jenkins-master job generated ................................................................................. 277
10.29. Artifactory Jenkins plugin configuration ................................................................. 280
10.30. Triggering several other builds after a build job ....................................................... 282
10.31. A build job dependency graph .............................................................................. 283
10.32. Configuring a join in the phoenix-web-tests build job ................................................ 284
10.33. A more complicated build job dependency graph ...................................................... 284
10.34. Adding a new lock ............................................................................................. 285
10.35. Configuring a build job to use a lock ..................................................................... 285
10.36. Configuring a Maven release using the M2Release plugin .......................................... 287
10.37. The Perform Maven Release menu option ............................................................... 287
10.38. Performing a Maven release in Jenkins ................................................................... 288
10.39. Adding a “Copy artifacts from another project” build step .......................................... 289
10.40. Running web tests against a copied WAR file .......................................................... 291
10.41. Copying from a multiconfiguration build ................................................................ 292
10.42. Build jobs in the promotion process ....................................................................... 293
10.43. Configuring a build promotion process ................................................................... 294
10.44. Configuring a manual build promotion process ........................................................ 295
10.45. Viewing the details of a build promotion ................................................................ 296
10.46. Using fingerprints in the build promotion process ..................................................... 297
10.47. Fetching the WAR file from the upstream build job .................................................. 297
10.48. Archiving the WAR file for use in the downstream job .............................................. 298
10.49. Fetching the WAR file from the integration job ........................................................ 298
10.50. We need to determine the fingerprint of the WAR file we use ..................................... 298
10.51. Fetching the latest promoted WAR file ................................................................... 299
10.52. Promoted builds are indicated by a star in the build history ......................................... 299
10.53. Reporting on aggregate test results ........................................................................ 300
10.54. Viewing aggregate test results ............................................................................... 301
10.55. Configuring a manual step in the build pipeline ........................................................ 302
10.56. Creating a Build Pipeline view .............................................................................. 302
10.57. Configuring a Build Pipeline view ......................................................................... 303
10.58. A Build Pipeline in action .................................................................................... 304
11.1. Managing slave nodes ........................................................................................... 306
11.2. Creating a new slave node ..................................................................................... 307
11.3. Creating a Unix slave node .................................................................................... 307
11.4. Taking a slave off-line when idle ............................................................................ 309
11.5. Configuring tool locations ..................................................................................... 310
11.6. Your new slave node in action ............................................................................... 310
11.7. Creating a slave node for JNLP .............................................................................. 311
11.8. Launching a slave via Java Web Start ...................................................................... 312
11.9.