SlideShare a Scribd company logo
Writing a Hudson / Jenkins plugin
Anthony Dahanne @ EclipseCon NA 2014, March 19th
EclipseCon NA 2014 — Writing a Hudson / Jenkins pluginConfoo 2013
About me …
"2
§ Software Engineer at Terracotta
– Working on EhCache management REST API and
webapp (aka Terracotta Management Console, TMC)
– Strong interest in CI & build tools (Maven, Jenkins,
Hudson, Nexus plugins author)
– Android developer when time permits ...
EclipseCon NA 2014 — Writing a Hudson / Jenkins pluginConfoo 2013
Terracotta
"3
§ Founded 2003 in San Francisco, CA
§ Joined Software AG in 2011
§ Present in India, Europe 

and pretty much all over the globe!
§ The company behind :
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Agenda
§ Jenkins / Hudson ? Quick intro
§ Do I need to create a plugin ?
§ Let’s build a plugin !
§ How to (integration) test this plugin
§ Share the plugin with the community
"4
Jenkins / Hudson ? Quick intro
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Jenkins / Hudson ?
§ Hudson is an open source Continuous Integration
(CI) tool created in 2005 by Kohsuke Kawaguchi
§ Became really popular from 2008
§ The project split in November 2010
§ Hudson moved to the Eclipse Foundation in May
2011
§ Still the most popular CI tool(s) in 2014
"6
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
InfoQ CI popularity results
"7
HudsonJenkins
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Jenkins / Hudson few differences (figures)
§ 5000 commits
§ 325 contributors
§ 70 000 installs (9/13)
§ 889 plugins
"8
§ 1230 commits
§ 15 contributors
§ 65 000 downloads (9/13)
§ 379 plugins
Since September 2011
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Jenkins / Hudson few differences (features)
§ plugins hot install
§ write views in Groovy
§ UI improvements
"9
§ maven3 plugin
§ cascading project settings
§ Eclipse IP clean
§ team concept
Since September 2011
Do I need to create a plugin ?
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Do we need yet another plugin ?
§ 100’s of existing plugins in the update centers !
§ Customized reports / trigger a build
– CLI
– Remote API
§ Groovy plugin(s)
– Allow you to run a groovy script during build or post build
"11
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Hudson / Jenkins CLI
§ You can list jobs, start them, delete them (same
applies for nodes)
!
§ $ java -jar hudson-cli.jar -s http://localhost:8080/ list-jobs	
§ $ java -jar hudson-cli.jar -s http://localhost:8080/ build
ehcache-jcache_master	
!
§ Perfect for command line scripts !
"12
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Remote API
§ Take any Hudson / Jenkins url, add
– /api/xml : xml representation of your view
– /api/json : json representation of your view
§ Depth to control the level of detail
– http://ci.jruby.org/api/xml?depth=1
§ Tree to specify what you want
– http://ci.jruby.org/api/xml?
tree=jobs[displayName,lastBuild[result]]
§ Enjoy powerful xpath filters (with /api/xml only)
– http://ci.jruby.org/api/xml?
tree=jobs[displayName,lastBuild[result]]&exclude=hudson/
job[lastBuild[result=%27SUCCESS%27]]
"13
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Groovy plugin(s)
§ Allow you to run a groovy script during build or post build
– EnvInject Plugin : inject System env. variable to your
build
– Groovy Postbuild plugin : execute a groovy script in the
Jenkins VM
§ Usage of those plugins is powerful (dangerous?), they
usually have access to the Jenkins API and runtime
"14
Let’s write a plugin !
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Let’s write a plugin !
§ hpi:create to bootstrap the creation
$ mvn org.eclipse.hudson.tools:maven-hpi-plugin:create	
§ hpi:run to run it in a fresh container
$ mvn package org.eclipse.hudson.tools:maven-hpi-plugin:run
"16
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
What got created
"17
Diagram copied from the book Hudson Continuous Integration in Practice
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Extensions points : job configuration
"18
SCM
Trigger
Axis
Builder
Recorder
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Extensions points : dashboard
"19
ListView ListViewColumnRootAction
PageDecorator
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Extensions points : job view
"20
TransientProjectActionFactory
BuildBadgeAction
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
UI Descriptor and Jelly views
"21
Use the class name for your resources folder
Plugin description (appears in the update center)
help caption for the field “name”
UI configuration for the system configuration page
UI configuration for the Job configuration page
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Variables accessible from Jelly
"22
§ app : maps to Hudson.getInstance()
§ app.getUrl() maps to Hudson.getInstance().getUrl()	
§ it : maps to the UI element rendered by Jelly
§ it.name maps to HelloWorldBuilder.getName()	
§ h : maps to the Functions class
§ h.jsStringEscape() maps to Functions.jsStringEscape()
How to (integrate) test a plugin
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Write integration tests
§ Write a class that extends HudsonTestCase
§ Benefit from its helper methods to configure
Hudson :
– createFreeStyleProject() and friends
– assertBuildStatus() and others
– WebClient.getPage() and WebAssert.assertElementPresent()	
§ or inject existing configuration with @LocalData
"24
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Write integration tests (local data layout)
"25
Use the class name for your resources folder
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Run your integration tests
§ From your IDE, Run as… / Debug as …
§ With Maven, the usual
– $ mvn clean test (-Dtest=org.my.Test)
§ A friend’s advice : fork your VM when running a test suite
§ Add in your pom :
"26
<build>	
<plugins>	
<plugin>	
<artifactId>maven-surefire-plugin</artifactId>	
<groupId>org.apache.maven.plugins</groupId>	
<configuration>	
<!-- make sure each test spawns a different vm -->	
<forkMode>always</forkMode>	
</configuration>	
</plugin>	
</plugins>	
</build>
Share the plugin with the community
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Share your Jenkins plugin with the community
§ Test it and target the lowest API level possible
§ Add Maven metadata
§ Ask jenkinsci-dev@googlegroups.com to create a
github repo to host your plugin
§ Create a wiki page on https://wiki.jenkins-ci.org/
display/JENKINS/Home
§ Release your plugin with maven to the Jenkins repo
§ Built on https://jenkins.ci.cloudbees.com/job/plugins/
"28
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
Share your Hudson plugin with the community
§ Test it and target the lowest API level possible
§ Add Maven metadata
§ Ask hudson-dev@eclipse.org to create a github repo
to host your plugin
§ Create a wiki page on http://wiki.hudson-ci.org
§ Release your plugin with maven to the Sonatype
OSS repo
§ Built on http://ci.hudson-ci.org/
"29
EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin
References
§ Hudson Continuous Integration in Practice, by Winston Prakash and Ed Burns
§ Jenkins User Conference 2011 (on slideshare)
§ Hudson (on wikipedia)
§ Writing your first Hudson plugin
§ List of Extension points
§ Writing tests for your plugin
§ Hosting Hudson plugins and Releasing Hudson plugins
§ Hosting and releasing Jenkins Plugins
§ InfoQ : What CI Server do you use ?
§ Developing a plugin for both Jenkins and Hudson
"30
Writing a Jenkins / Hudson plugin

More Related Content

PPTX
Jenkins Plugin Development With Gradle And Groovy
PDF
From devOps to front end Ops, test first
KEY
Writing your Third Plugin
PPTX
JavaScript All The Things
PDF
探討Web ui自動化測試工具
PPTX
Grooving with Jenkins
PDF
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
PDF
Welcome to Jenkins
Jenkins Plugin Development With Gradle And Groovy
From devOps to front end Ops, test first
Writing your Third Plugin
JavaScript All The Things
探討Web ui自動化測試工具
Grooving with Jenkins
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Welcome to Jenkins

What's hot (20)

PDF
JavaScript + Jenkins = Winning!
PDF
Acceptance testing with Geb
PDF
Instrumentación de entrega continua con Gitlab
PPT
Learn jobDSL for Jenkins
PDF
DevOps叢林裡的小隊游擊戰術 (@ iThome DevOps 2015)
PDF
Taming Functional Web Testing with Spock and Geb
PPTX
Deploy Node.js application in Heroku using Eclipse
PPTX
Intro to JavaScript Tooling in Visual Studio Code
PDF
淺談 Groovy 與 AWS 雲端應用開發整合
PPT
Dockerizing BDD : Ruby-Cucumber Example
PDF
Jenkins and Groovy
PDF
Automatisation in development and testing - within budget
PDF
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
PDF
Ant, Maven and Jenkins
PDF
Moderne Android Builds mit Gradle
PDF
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
PPT
Building and Deployment of Drupal sites with Features and Context
PDF
Jenkinsプラグインの作り方
PDF
Docker, Ansible and Symfony micro-kernel
PDF
Git best practices workshop
JavaScript + Jenkins = Winning!
Acceptance testing with Geb
Instrumentación de entrega continua con Gitlab
Learn jobDSL for Jenkins
DevOps叢林裡的小隊游擊戰術 (@ iThome DevOps 2015)
Taming Functional Web Testing with Spock and Geb
Deploy Node.js application in Heroku using Eclipse
Intro to JavaScript Tooling in Visual Studio Code
淺談 Groovy 與 AWS 雲端應用開發整合
Dockerizing BDD : Ruby-Cucumber Example
Jenkins and Groovy
Automatisation in development and testing - within budget
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Ant, Maven and Jenkins
Moderne Android Builds mit Gradle
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
Building and Deployment of Drupal sites with Features and Context
Jenkinsプラグインの作り方
Docker, Ansible and Symfony micro-kernel
Git best practices workshop
Ad

Viewers also liked (20)

PDF
XebiaLabs @ Jenkins User Conference Boston 2014
PDF
Infinit filesystem, Reactor reloaded
PDF
Persistent storage tailored for containers #dockersummit
PDF
Docker volume plugins and Infinit – Mini-conf Docker Paris #1
PPTX
Let's Build a Service Oriented Data Pipeline!
PDF
Super Charged Configuration As Code
PPTX
Jenkins Job DSL plugin
PDF
Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014
PPTX
#ListenLearnLead - 2015 International Women's Day Research
PDF
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
PDF
Synchronizing parallel delivery flows in jenkins using groovy, build flow and...
PDF
groovy and concurrency
DOC
analiza economico finaniara la firma x
ODP
Jenkins 101: Continuos Integration with Jenkins
PPT
Jenkins Scriptler in 90mins
PPT
Groovy Maven Builds
PPTX
Job DSL Plugin for Jenkins
PDF
Continuous Development Pipeline
PDF
Building an Extensible, Resumable DSL on Top of Apache Groovy
PPTX
Jenkins days workshop pipelines - Eric Long
XebiaLabs @ Jenkins User Conference Boston 2014
Infinit filesystem, Reactor reloaded
Persistent storage tailored for containers #dockersummit
Docker volume plugins and Infinit – Mini-conf Docker Paris #1
Let's Build a Service Oriented Data Pipeline!
Super Charged Configuration As Code
Jenkins Job DSL plugin
Continuous Delivery of Puppet-Based Infrastructure - PuppetConf 2014
#ListenLearnLead - 2015 International Women's Day Research
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Synchronizing parallel delivery flows in jenkins using groovy, build flow and...
groovy and concurrency
analiza economico finaniara la firma x
Jenkins 101: Continuos Integration with Jenkins
Jenkins Scriptler in 90mins
Groovy Maven Builds
Job DSL Plugin for Jenkins
Continuous Development Pipeline
Building an Extensible, Resumable DSL on Top of Apache Groovy
Jenkins days workshop pipelines - Eric Long
Ad

Similar to Writing a Jenkins / Hudson plugin (20)

PPTX
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
PPTX
Jenkins State of union 2013
PDF
Jenkins CI
PPTX
Jenkins user conference 2011
PDF
Introduction To Jenkins - SpringPeople
PDF
454976614-Jenkins-Cheat-Sheet-pdf.pdf hoja de ayuda
PPTX
varun JENKINS.pptx
PPTX
Ordina Accelerator program 2019 - Jenkins blue ocean pipelines
PDF
Jenkins_1679702972.pdf
PDF
jenkins.pdf
PPTX
Continuous Integration Fundamentals: Build Automation - OFM Canberra October ...
PPTX
CI from scratch with Jenkins (EN)
PPTX
Jenkins an opensource CICD platform for all
PPT
Jenkins Overview
PPTX
To TDD or not to TDD - that is the question
PPTX
PDF
PPTX
Jenkins for java world
PPTX
Introduction to jenkins
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Jenkins State of union 2013
Jenkins CI
Jenkins user conference 2011
Introduction To Jenkins - SpringPeople
454976614-Jenkins-Cheat-Sheet-pdf.pdf hoja de ayuda
varun JENKINS.pptx
Ordina Accelerator program 2019 - Jenkins blue ocean pipelines
Jenkins_1679702972.pdf
jenkins.pdf
Continuous Integration Fundamentals: Build Automation - OFM Canberra October ...
CI from scratch with Jenkins (EN)
Jenkins an opensource CICD platform for all
Jenkins Overview
To TDD or not to TDD - that is the question
Jenkins for java world
Introduction to jenkins

More from Anthony Dahanne (20)

PDF
JDConf 2025 - Paketo Buildpacks : the best way to build Java container images
PPTX
Not a Kubernetes fan? The state of PaaS in 2025
PPTX
No More Dockerfiles! Buildpacks to Help You Ship Your Image!
PDF
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
PPTX
Not a Kubernetes fan? The state of PaaS in 2024
PPTX
No more Dockerfiles? Buildpacks to help you ship your image!
PPTX
CNCF Québec Meetup du 16 Novembre 2023
PDF
Buildpacks: the other way to build container images
PDF
Tu changes d'emploi - retour d'experience d'un développeur
PPTX
Java applications containerized and deployed
PDF
Contribuer à la traduction française de kubernetes
PDF
Get you Java application ready for Kubernetes !
PDF
Kubernetes Java Operator
PDF
Caching in applications still matters
PDF
Kubernetes for java developers - Tutorial at Oracle Code One 2018
PDF
Kubernetes for Java Developers
PDF
Docker and java
PDF
Terracotta Ehcache : Simpler, faster, distributed
PPTX
Docker and java, at Montréal JUG
PDF
Confoo2013 make your java-app rest enabled
JDConf 2025 - Paketo Buildpacks : the best way to build Java container images
Not a Kubernetes fan? The state of PaaS in 2025
No More Dockerfiles! Buildpacks to Help You Ship Your Image!
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Not a Kubernetes fan? The state of PaaS in 2024
No more Dockerfiles? Buildpacks to help you ship your image!
CNCF Québec Meetup du 16 Novembre 2023
Buildpacks: the other way to build container images
Tu changes d'emploi - retour d'experience d'un développeur
Java applications containerized and deployed
Contribuer à la traduction française de kubernetes
Get you Java application ready for Kubernetes !
Kubernetes Java Operator
Caching in applications still matters
Kubernetes for java developers - Tutorial at Oracle Code One 2018
Kubernetes for Java Developers
Docker and java
Terracotta Ehcache : Simpler, faster, distributed
Docker and java, at Montréal JUG
Confoo2013 make your java-app rest enabled

Recently uploaded (20)

PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Machine learning based COVID-19 study performance prediction
PDF
KodekX | Application Modernization Development
PDF
Approach and Philosophy of On baking technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
Teaching material agriculture food technology
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Network Security Unit 5.pdf for BCA BBA.
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
The AUB Centre for AI in Media Proposal.docx
Empathic Computing: Creating Shared Understanding
Machine learning based COVID-19 study performance prediction
KodekX | Application Modernization Development
Approach and Philosophy of On baking technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Dropbox Q2 2025 Financial Results & Investor Presentation
The Rise and Fall of 3GPP – Time for a Sabbatical?
Teaching material agriculture food technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Big Data Technologies - Introduction.pptx
Chapter 3 Spatial Domain Image Processing.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”

Writing a Jenkins / Hudson plugin

  • 1. Writing a Hudson / Jenkins plugin Anthony Dahanne @ EclipseCon NA 2014, March 19th
  • 2. EclipseCon NA 2014 — Writing a Hudson / Jenkins pluginConfoo 2013 About me … "2 § Software Engineer at Terracotta – Working on EhCache management REST API and webapp (aka Terracotta Management Console, TMC) – Strong interest in CI & build tools (Maven, Jenkins, Hudson, Nexus plugins author) – Android developer when time permits ...
  • 3. EclipseCon NA 2014 — Writing a Hudson / Jenkins pluginConfoo 2013 Terracotta "3 § Founded 2003 in San Francisco, CA § Joined Software AG in 2011 § Present in India, Europe 
 and pretty much all over the globe! § The company behind :
  • 4. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Agenda § Jenkins / Hudson ? Quick intro § Do I need to create a plugin ? § Let’s build a plugin ! § How to (integration) test this plugin § Share the plugin with the community "4
  • 5. Jenkins / Hudson ? Quick intro
  • 6. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Jenkins / Hudson ? § Hudson is an open source Continuous Integration (CI) tool created in 2005 by Kohsuke Kawaguchi § Became really popular from 2008 § The project split in November 2010 § Hudson moved to the Eclipse Foundation in May 2011 § Still the most popular CI tool(s) in 2014 "6
  • 7. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin InfoQ CI popularity results "7 HudsonJenkins
  • 8. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Jenkins / Hudson few differences (figures) § 5000 commits § 325 contributors § 70 000 installs (9/13) § 889 plugins "8 § 1230 commits § 15 contributors § 65 000 downloads (9/13) § 379 plugins Since September 2011
  • 9. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Jenkins / Hudson few differences (features) § plugins hot install § write views in Groovy § UI improvements "9 § maven3 plugin § cascading project settings § Eclipse IP clean § team concept Since September 2011
  • 10. Do I need to create a plugin ?
  • 11. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Do we need yet another plugin ? § 100’s of existing plugins in the update centers ! § Customized reports / trigger a build – CLI – Remote API § Groovy plugin(s) – Allow you to run a groovy script during build or post build "11
  • 12. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Hudson / Jenkins CLI § You can list jobs, start them, delete them (same applies for nodes) ! § $ java -jar hudson-cli.jar -s http://localhost:8080/ list-jobs § $ java -jar hudson-cli.jar -s http://localhost:8080/ build ehcache-jcache_master ! § Perfect for command line scripts ! "12
  • 13. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Remote API § Take any Hudson / Jenkins url, add – /api/xml : xml representation of your view – /api/json : json representation of your view § Depth to control the level of detail – http://ci.jruby.org/api/xml?depth=1 § Tree to specify what you want – http://ci.jruby.org/api/xml? tree=jobs[displayName,lastBuild[result]] § Enjoy powerful xpath filters (with /api/xml only) – http://ci.jruby.org/api/xml? tree=jobs[displayName,lastBuild[result]]&exclude=hudson/ job[lastBuild[result=%27SUCCESS%27]] "13
  • 14. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Groovy plugin(s) § Allow you to run a groovy script during build or post build – EnvInject Plugin : inject System env. variable to your build – Groovy Postbuild plugin : execute a groovy script in the Jenkins VM § Usage of those plugins is powerful (dangerous?), they usually have access to the Jenkins API and runtime "14
  • 15. Let’s write a plugin !
  • 16. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Let’s write a plugin ! § hpi:create to bootstrap the creation $ mvn org.eclipse.hudson.tools:maven-hpi-plugin:create § hpi:run to run it in a fresh container $ mvn package org.eclipse.hudson.tools:maven-hpi-plugin:run "16
  • 17. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin What got created "17 Diagram copied from the book Hudson Continuous Integration in Practice
  • 18. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Extensions points : job configuration "18 SCM Trigger Axis Builder Recorder
  • 19. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Extensions points : dashboard "19 ListView ListViewColumnRootAction PageDecorator
  • 20. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Extensions points : job view "20 TransientProjectActionFactory BuildBadgeAction
  • 21. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin UI Descriptor and Jelly views "21 Use the class name for your resources folder Plugin description (appears in the update center) help caption for the field “name” UI configuration for the system configuration page UI configuration for the Job configuration page
  • 22. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Variables accessible from Jelly "22 § app : maps to Hudson.getInstance() § app.getUrl() maps to Hudson.getInstance().getUrl() § it : maps to the UI element rendered by Jelly § it.name maps to HelloWorldBuilder.getName() § h : maps to the Functions class § h.jsStringEscape() maps to Functions.jsStringEscape()
  • 23. How to (integrate) test a plugin
  • 24. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Write integration tests § Write a class that extends HudsonTestCase § Benefit from its helper methods to configure Hudson : – createFreeStyleProject() and friends – assertBuildStatus() and others – WebClient.getPage() and WebAssert.assertElementPresent() § or inject existing configuration with @LocalData "24
  • 25. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Write integration tests (local data layout) "25 Use the class name for your resources folder
  • 26. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Run your integration tests § From your IDE, Run as… / Debug as … § With Maven, the usual – $ mvn clean test (-Dtest=org.my.Test) § A friend’s advice : fork your VM when running a test suite § Add in your pom : "26 <build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId> <configuration> <!-- make sure each test spawns a different vm --> <forkMode>always</forkMode> </configuration> </plugin> </plugins> </build>
  • 27. Share the plugin with the community
  • 28. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Share your Jenkins plugin with the community § Test it and target the lowest API level possible § Add Maven metadata § Ask jenkinsci-dev@googlegroups.com to create a github repo to host your plugin § Create a wiki page on https://wiki.jenkins-ci.org/ display/JENKINS/Home § Release your plugin with maven to the Jenkins repo § Built on https://jenkins.ci.cloudbees.com/job/plugins/ "28
  • 29. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin Share your Hudson plugin with the community § Test it and target the lowest API level possible § Add Maven metadata § Ask hudson-dev@eclipse.org to create a github repo to host your plugin § Create a wiki page on http://wiki.hudson-ci.org § Release your plugin with maven to the Sonatype OSS repo § Built on http://ci.hudson-ci.org/ "29
  • 30. EclipseCon NA 2014 — Writing a Hudson / Jenkins plugin References § Hudson Continuous Integration in Practice, by Winston Prakash and Ed Burns § Jenkins User Conference 2011 (on slideshare) § Hudson (on wikipedia) § Writing your first Hudson plugin § List of Extension points § Writing tests for your plugin § Hosting Hudson plugins and Releasing Hudson plugins § Hosting and releasing Jenkins Plugins § InfoQ : What CI Server do you use ? § Developing a plugin for both Jenkins and Hudson "30