Jenkins User Conference Jenkins User Conference San Francisco, Sept #jenkinsconf Take Control. Write a Plugin. Part II Baruch Sadogursky JFrog
About me Developer Job definition: Write code Talk about it
With Jenkins from day 1 Jenkins Artifactory Plugin Hosted JUC Israel repo.jenkins-ci.org JavaOne DEMOzone JFrog & Jenkins
Vote and guessing Working with remote agents Working in multiple operation systems Creating UI using Groovy Writing custom Jelly(?) tags Maintaining backwards compatibility Agenda
Vote and guessing Working with remote agents Working in multiple operation systems Creating UI using Groovy Writing custom Jelly(?) tags Maintaining backwards compatibility Agenda
Who saw “Take Control. Write a Plugin” session on YouTube?“Take Control. Write a Plugin” session on YouTube Let me guess… one or two hands… First, let’s vote
PREVIOUSLY IN “TAKE CONTROL. WRITE A PLUGIN”… “Hello, my name is Noam Tenne”
What you can do with plugins What you can’t do with plugins Plugins statistics Overview – Why plugins
UI SCM Build Processes Slave management Tooling... Many, many, more You can even create new extension points! What can I extend?
IDE All majors have good support We love IntelliJ IDEA Build tool Can be Maven or Gradle Environment
Target: Rewarding failing builds with insulting mockery Global configuration: Motivation phrase Project configuration: Is motivator enabled Outcome: Message appears in log after failure The “Motivation” Plugin
BACK TO OUR AGENDA Nowdays…
Vote and guessing Working with remote agents Working in multiple operation systems Creating UI using Groovy Writing custom Jelly(?) tags Maintaining backwards compatibility Agenda
Jenkins has remote agents! Working with remote agents
Send closures to remote agents hudson.remoting.Callable Working with remote agents Java Serialization
Poor guy’s Java closure Usually anonymous inner class (not always) Closure
Channel? Cast your bread on the waters
Represents a communication channel to the remote peer Obtain from: Channel
Where is the file? Distribution Abstractions – FilePath
hudson.FilePath Much like java.util.File Consider pushing logic to the file Use FilePath.act(FileCallable) Distribution Abstractions – FilePath
Launch stuff remotely! Distribution Abstractions – Launcher
hudson.Launcher Much like java.lang.ProcessBuilder Pick your environment variables wisely! Distribution Abstractions – Launcher
Vote and guessing Working with remote agents Working in multiple operation systems Creating UI using Groovy Writing custom Jelly(?) tags Maintaining backwards compatibility Agenda
WORA. You know. But. / vs \.sh vs. bat Quotes around commands Permissions (wait for it…) Working in multiple OSs
Executing file… remotely… platform independent… Running script…
Can You Spot The Error? Executed locally!
Use FilePath – it will take care of all the details! Execute FilePath.act(FileCallable) If you need the File API, invoke() method has it, converted to remote file properly Going Remote with File
Permissions Dance
Vote and guessing Working with remote agents Working in multiple operation systems Creating UI using Groovy Writing custom Jelly(?) tags Maintaining backwards compatibility Agenda
First, let’s look at the docs: Creating UI using Groovy
Analogous to Jelly Can use Jelly tags and libraries Kohsuke: Creating UI using Groovy WhenWhat Lots of program logicGroovy Lots of HTML layout markupJelly
Analogous to Jelly Can use Jelly tags and libraries me: Creating UI using Groovy WhenWhat Always!Groovy
Jelly: Groovy: Creating UI using Groovy
Real code Debuggable, etc. (stay tuned…)
Vote and guessing Working with remote agents Working in multiple operation systems Creating UI using Groovy Writing custom Jelly(?) tags Maintaining backwards compatibility Agenda
Documentation: Writing custom Jelly(?) tags
Simple as 1,2… that’s it. Writing custom Jelly Groovy tags
1. Implement
2. Use!
Vote and guessing Working with remote agents Working in multiple operation systems Creating UI using Groovy Writing custom Jelly(?) tags Maintaining backwards compatibility Agenda
Back to Motivation plugin… Maintaining backwards compatibility
Rename defaultMotivatingMessage to motivatingMessage What happens to existing configuration on users machines? Refactoring!
Register field (or class) alias In Initializer that runs before plugins started More complex cases might reqiure XStream converter XStream Aliasing To The Rescue
See you at our DEMOzone! Thank you!
Thank You To Our Sponsors