Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Bringing Jenkins Remote Access API To The Masses

1,110 views

Published on

Delivered at Jenkins World 2017.
https://jenkinsworld20162017.sched.com/event/ALN6/bringing-jenkins-remote-access-api-to-the-masses

Published in: Technology
  • Be the first to comment

Bringing Jenkins Remote Access API To The Masses

  1. 1. Bringing Jenkins Remote Access API To The Masses Cliffano Subagio (@cliffano) - Shine Solutions
  2. 2. G’Day Cliffano Subagio (@cliffano) Shine Solutions, Australia Jenkins (nee Hudson) - User since 2007 - Contributor since 2008
  3. 3. Menu: - Jenkins and I - Remote Access API - Introducing Swaggy Jenkins - Demo Time - What’s next?
  4. 4. Once upon a time…
  5. 5. My Mission: To extend Jenkins.
  6. 6. 1. Chuck Norris Plugin
  7. 7. 2. JSGames Plugin
  8. 8. 3. Speakable Items
  9. 9. 4. Firefox Add-on Build Monitor
  10. 10. 5. Nestor
  11. 11. Remote Access API: What Is It? • REST-like style • HTTP basic authentication • CSRF protection token • JSON/XML responses
  12. 12. Remote Access API: What Can It Do? • Build, create, delete, enable, disable a job • Create, delete a view • Get job and view config.xml • List jobs status, queued jobs, executors • Get build console output • Get Jenkins version
  13. 13. Build A Job + Stream Console Output
  14. 14. Build A Job + Stream Console Output
  15. 15. Client Library api = new RemoteAccessApi(username, password); crumb = api.getCrumb(); api.setCrumb(crumb); job = api.buildJob(‘myjob’); job.isInQueue(); job.getConsoleOutput();
  16. 16. Existing Client Libraries • node.js: jenkins, jenkins-api,jenkins2-api, smithers • python: pyjenkins, jenkins-webapi, jenkins-build • ruby: jenkins, jenkins_api_client, jenkins-json-api • perl: Jenkins::API, Net::Jenkins • More…
  17. 17. Challenges I’m Trying To Solve • Lack of parity between clients • Maintainers availability • Growing number of technology stacks
  18. 18. Introducing Swagger CodeGen • Generates code from an OpenAPI specification • Endpoints, parameters, models • Support 70+ technology stacks
 and counting…
  19. 19. Supported Technology Stacks
  20. 20. My New Mission: To enable others to integrate Jenkins with as many technologies as possible.
  21. 21. Introducing Swaggy Jenkins • Code generated from OpenAPI spec for Jenkins • Rapid change and regenerate! • 70+ libraries • Published to npmjs.com, PyPI, RubyGems.org
 More to follow… • Available on github.com/cliffano/swaggy-jenkins
  22. 22. Building An OpenAPI Specification • Specify info, schemes, security • Specify paths, parameters, responses • Generate response model definitions • Total: 2840 lines long
 45% of which are response model definitions
  23. 23. Converting Response Models Jenkins response JSON OpenAPI Definitions
  24. 24. Generating Response Model Definitions • `swaggy-jenkins response2definition
 remoteaccess-responses/
 --reporter file
 --out-file remoteaccess-definitions.yml` • Result: 1274 lines of definitions • Regenerate when there’s a response JSON update
  25. 25. 70+ Generated Libraries
  26. 26. Demo 1: Nestor CLI + Remote Access API
  27. 27. Demo 2 - api.ai + Remote Access API
  28. 28. Demo 3: Slack Chatbot + Blue Ocean API
  29. 29. What Is Blue Ocean API? • Used by Blue Ocean UX • Private API • JSON Web Token • Pipeline, run, queue, log • User, organisation, SCM
  30. 30. Run A Pipeline
  31. 31. What’s Next? • Upgrade to OpenAPI 3.0 • JWT authentication support • Folder support • Future of Jenkins API?
  32. 32. Conclusions
  33. 33. Resources • Swaggy Jenkins - https://github.com/cliffano/swaggy- jenkins • Nestor - https://github.com/cliffano/nestor • Jenkins api.ai Demo - https://github.com/cliffano/jenkins- apiai-demo • Jenkins Slack Demo - https://github.com/cliffano/jenkins- slack-demo • Jenkins Remote Access API - https://wiki.jenkins.io/display/ jenkins/remote+access+api • Jenkins Blue Ocean API - https://github.com/jenkinsci/ blueocean-plugin/tree/master/blueocean-rest
  34. 34. Questions?

×