|
| 1 | +# Jenkins World 2017 |
| 2 | + |
| 3 | +This talk was presented during Jenkins World 2017 in San Francisco, CA on August 29th-31st. |
| 4 | + |
| 5 | +## Presentation |
| 6 | + |
| 7 | +[2017_Jenkins_World_VictorMartinez.pdf](2017_Jenkins_World_VictorMartinez.pdf) contains the slides of the presentation. |
| 8 | + |
| 9 | +*NOTE*: The presentation was recorded although the video URL hasn't been released yet. |
| 10 | + |
| 11 | +## Best Practices |
| 12 | + |
| 13 | +You can find some example groovy scripts to analyse what Jenkins projects don't follow those practices. |
| 14 | + |
| 15 | +It does use the internal Jenkins API and therefore you need to be cautious to avoid doing evil things: |
| 16 | + |
| 17 | +* http://unethicalblogger.com/2017/08/03/donut-disable-groovy-sandbox.html |
| 18 | + |
| 19 | +Bear in mind, some of those scripts are just read only but others are also adding some details in the project description and also disabling those jobs. |
| 20 | + |
| 21 | +This groovy implementation is just a basic/simple implementation, it might not cover all the use cases. The final solution was implemented as a Jenkins Plugin called Jenkins Lint plugin. |
| 22 | + |
| 23 | +* [Example 1](groovy/description.groovy) - shows list of projects without any description |
| 24 | +* [Example 2](groovy/spaces.groovy) - shows list of projects with whitespaces in their name |
| 25 | +* [Example 3](groovy/label.groovy) - shows list of projects without any label restriction |
| 26 | +* [Example 4](groovy/workspace.groovy) - shows list of projects without any workspace cleanup policy |
| 27 | +* [Example 5](groovy/logrotator.groovy) - shows list of projects without any log rotator policy or empty values |
| 28 | +* [Example 6](groovy/pushing.groovy) - shows list of projects using polling |
| 29 | +* [Example 7](groovy/shallow.groovy) - shows list of projects which use git but no shallow cloning |
| 30 | +* [Example 8](groovy/reference.groovy) - shows list of projects which use git but no git reference repos |
| 31 | +* [Example 9](groovy/system_exit.groovy) - shows list of Projects which some system exit when using groovy post build actions |
| 32 | +* [Example 10](groovy/groovy_sandbox.groovy) - shows list of pipelines without the groovy sandbox option |
| 33 | +* [Example 11](groovy/maven.groovy) - shows list of Maven job types |
| 34 | +* [Example 12](groovy/timeout.groovy) - shows list of projects which don't use the Build Timeout plugin |
| 35 | +* [Example 13](groovy/bfa.groovy) - shows list of projects which don't use the Build Failure plugin |
| 36 | + |
| 37 | +### How to run them |
| 38 | + |
| 39 | +* Open the script console page: This feature can be accessed from the "manage Jenkins" link, typically at your http://server/jenkins/script. [ScriptConsole Wiki](https://wiki.jenkins.io/display/JENKINS/Jenkins+Script+Console) |
| 40 | +* Copy one of those groovy Script and paste in the script console text area. |
| 41 | +* Run and look at the output. |
| 42 | + |
| 43 | +## Further details |
| 44 | +For more information on JenkinsLint, please visit [JenkinsLint](https://plugins.jenkins.io/jenkinslint). |
| 45 | + |
| 46 | +There are even further examples of using the internal Jenkins API in the below links: |
| 47 | +* https://github.com/jenkinsci/jenkins-scripts/tree/master/scriptler |
0 commit comments