Extending Blue Ocean Keith Zantow

Similar documents
Full Stack Developer with Java

Arjen de Blok. Senior Technical Consultant bij ICT Groep ( sinds 1995 Programmeren sinds 1990 Technologiën. Links

Jenkins 2 UX Improvements. Keith Zantow Software Engineer, CloudBees, Inc.

"Charting the Course... MOC A: Developing with the SharePoint Framework. Course Summary

Web Development for Dinosaurs An Introduction to Modern Web Development

Getting Started with ReactJS

Frontend UI Training. Whats App :

55249: Developing with the SharePoint Framework Duration: 05 days

Templates and Databinding. SWE 432, Fall 2017 Design and Implementation of Software for the Web

vrealize Code Stream Plug-In SDK Development Guide

Lab 1 - Introduction to Angular

AEM React. History. 1 Introduction. AEM components written in React. Why React and AEM? Features. Projects. date author message changed chapters

Advance Mobile& Web Application development using Angular and Native Script

Tools. SWE 432, Fall Design and Implementation of Software for the Web

Full Stack boot camp

Stencil: The Time for Vanilla Web Components has Arrived

Advanced React JS + Redux Development

React(.js) the Domino Way High-Performance Client for Domino. Knut Herrmann

Webpack. What is Webpack? APPENDIX A. n n n

Selenium Testing Course Content

A JavaScript Framework for Presentations and Animations on Computer Science

An Introduction to Eclipse Che Lets build a custom cloud IDE. October 2015 Tyler Jewell, Eclipse Che Project

Drew Skwiers-Koballa. Azure Data Studio Extension Development

"Charting the Course... Comprehensive Angular. Course Summary

Modern SharePoint and Office 365 Development

WebStorm, intelligent IDE for JavaScript development

ANGULAR 2.X,4.X + TYPESRCIPT by Sindhu

ReactJS and Webpack for Rails

Introduction to the SharePoint Framework Bob German Principal Architect - BlueMetal. An Insight company

Welcome. Quick Introductions

React & Redux in Hulu. (Morgan Cheng)

Vue.js Developer friendly, Fast and Versatile

Learn Web Development CodersTrust Polska course outline. Hello CodersTrust! Unit 1. HTML Structuring the Web Prerequisites Learning pathway.

DrupalCon Barcelona Preston So September 22, 2015

Front End Nanodegree Syllabus

An Automatic Internationalization and Localization Mechanism for Web Applications

Building a (resumable and extensible) DSL with Apache Groovy Jesse Glick CloudBees, Inc.

django-baton Documentation

Continuous Integration INRIA

20480C: Programming in HTML5 with JavaScript and CSS3. Course Code: 20480C; Duration: 5 days; Instructor-led. JavaScript code.

Getting started with Tabris.js Tutorial Ebook

Presented by. Dheepa Iyer Managing Consultant. Commissioned for. Reston SharePoint User Group. SharePoint Framework. May 2017

Angular 2 and TypeScript Web Application Development

6 JAVASCRIPT PROJECTS

Extensible Components with Sling Models and HTL

Catbook Workshop: Intro to NodeJS. Monde Duinkharjav

React + React Native. Based on material by Danilo Filgueira

Front End. Presentation Layer. UI (User Interface) User <==> Data access layer

Modern frontend workflows in Liferay Portal and Liferay DXP. Iván Zaera Avellon, Liferay Chema Balsas, Liferay Pier Paolo Ramon, SMC

npm install [<name> [<name>...]] [--save --save-dev --save-optional]

CodeHub. Curran Kelleher 8/18/2012

RequireJS Javascript Modules for the Browser. By Ben Keith Quoin, Inc.

Index. Elad Elrom 2016 E. Elrom, Pro MEAN Stack Development, DOI /

JavaScript Rd2. -Kyle Simpson, You Don t Know JS

Brunch Documentation. Release Brunch team

MOdern Java(Script) Server Stack

Angular 2 Programming

Introduction to Sencha Ext JS

Red Hat Developer Studio 12.0

Web Performance in

The Actual Real World at EclipseCon/ALM

Packaging, automation, Continuous Integration

Overview of BC Learning Network SMS2 Introduction

Chapter 1 - Development Setup of Angular

PHP WITH ANGULAR CURRICULUM. What you will Be Able to Achieve During This Course

django-baton Documentation

Catbook Workshop 1: Client Side JS. Danny Tang

Introduction: Manual Testing :

6 th October 2018 Milan

INF Introduction. Knut Staring gmail}

Cisco Spark Widgets Technical drill down

Hacking with React. Get started with React, React Router, Jest, Webpack, ES6 and more with this hands-on guide. Paul Hudson.

IN4MATX 133: User Interface Software

Cordova - Guide - Custom Plugins

AngularJS Fundamentals

THE PRAGMATIC INTRO TO REACT. Clayton Anderson thebhwgroup.com WEB AND MOBILE APP DEVELOPMENT AUSTIN, TX

August, HPE Propel Microservices & Jumpstart

PHP + ANGULAR4 CURRICULUM 6 WEEKS

Red Hat JBoss Developer Studio 11.3

Writing your first Web Data Connector

JavaScript Frameworks

JavaScript and MVC Frameworks FRONT-END ENGINEERING

What is Maven? Apache Maven is a software project management and comprehension tool (build, test, packaging, reporting, site, deploy).

30 th September 2017 Milan

Maven Introduction to Concepts: POM, Dependencies, Plugins, Phases

5th April Installation Manual. Department of Computing and Networking Software Development Degree

Moving From Studio to Atelier. Wouter Dupré Sales Engineer

Front End Nanodegree Syllabus

JavaScript Fundamentals_

APACHE SLING & FRIENDS TECH MEETUP SEPTEMBER Integrating a Modern Frontend Setup with AEM Natalia Venditto, Netcentric

React Loadable: Code Splitting with Server Side Rendering

UNIT -II. Language-History and Versions Introduction JavaScript in Perspective-

widgetjs Documentation

LeanJS Documentation. Release Romain Dorgueil

EnterSpace Data Sheet

Quick Desktop Application Development Using Electron

Guides SDL Server Documentation Document current as of 04/06/ :35 PM.

Nick Senger & Jesse van den Kieboom

Webpack 2 The last bundler you would need in Vijay Dharap, Principal Architect, Infosys

MARIA KERN NETZ98 GMBH MAGENTO 2 UI COMPONENTS THE JS PART

Transcription:

Extending Blue Ocean Keith Zantow

About Keith Senior Software Engineer at CloudBees, Inc. Jenkins & Blue Ocean core contributor 15+ years full-stack development Github: kzantow

Intended Audience Development experience Java JavaScript HTML & CSS Node Existing Jenkins plugin development experience or desire to implement a plugin for Blue Ocean

Example Code github.com/kzantow/blueocean-executor-info-plugin

Introduction

Recap: what is Blue Ocean? Re-thinking of the Jenkins user experience Focused on Pipeline Visualisation Creation Editing Extensible, like Jenkins

Blue Ocean

Pipeline Creation

Pipeline Editor

Pipeline Visualization: Execution

Pipeline Visualization: Post-Execution

Pipeline Visualization: Post-Execution

Pipeline Activity

How is it built?

Technologies Used Java (java.sun.com) Maven (maven.apache.org) Stapler (stapler.kohsuke.org) React (facebook.github.io/react) MobX (mobx.js.org) Node * (nodejs.org) Babel * (babeljs.io) LESS * (lesscss.org) too many more to list here * build-time only

React? Node? Wut? React: a modern, well maintained component framework JSX: familiar syntax that aids React development Node ecosystem has tools to expedite front-end development Babel: transpile JSX, ES7 -> ES5

MobX? Makes state management across the React tree easier to understand Automatically updates components when data is updated

js-modules, js-builder & js-extensions Creates bundles containing CommonJS modules js-modules built to load things from Jenkins js-builder is a gulp buld & plugin for Browserify to build js-modules compatible bundles with easy js-extensions is a plugin for js-builder that processes the jenkins-js-extensions.yaml

Building a plugin The basics

Quick starts Yeoman plugin generator-blueocean-usain Maven Archetype almost Copy/pasta Blue Ocean Executor Info Plugin

Project Structure Based on Maven: / / / /.mvn_exec_node - tells Maven to use maven-frontend-plugin package.json - node build info pom.xml - maven build src/main/js / jenkins-js-extension.yaml - defines extensions / src/main/less / extensions.less - defines css rules

pom.xml <project...> <parent> <groupid>org.jenkins-ci.plugins</groupid> <artifactid>plugin</artifactid> <version>2.30</version> </parent> <name>blue Ocean Executor Info</name> <artifactid>blueocean-executor-info-plugin</artifactid> <packaging>hpi</packaging>

pom.xml <properties> <blueocean.version>1.2.0</blueocean.version> </properties> <dependencies> <dependency> <groupid>io.jenkins.blueocean</groupid> <artifactid>blueocean</artifactid> <version>${blueocean.version}</version> </dependency>...

package.json { "name": "blueocean-pipeline-agent-info", "version": "0.0.0", "scripts": { "bundle:watch": "jjsbuilder --tasks bundle:watch", "mvnbuild": "jjsbuilder --tasks bundle", "mvntest": "jjsbuilder --tasks test" },...

package.json "devdependencies": { "@jenkins-cd/blueocean-core-js": "0.0.150", "@jenkins-cd/design-language": "0.0.145", "@jenkins-cd/js-builder": "0.0.59", "@jenkins-cd/js-extensions": "0.0.36",... }, "dependencies": { "@jenkins-cd/js-modules": "0.0.8", }

mvn hpi:run & npm run bundle:watch mvn install hpi:run - builds and runs the plugin npm run bundle:watch - recompile js & less while editing * Gotcha: extension changes won t update without restart

Debugging the UI Chrome developer tools are your friend! Sources transpiled - find unique strings console.log(<object>) js-logging

Plugin Overview

What do we want to do? Write a REST endpoint to provide some data Add a top-level link to a new page Add a simple page that provides access to the data Add something within an existing page Make the extension point live update Use modern ES6/7

Sample plugin: show executor info Provide API that returns executor status & metadata Add a link & page to display all computers & executors Add active executors to a pipeline list (branches grumble)

Constructing the plugin Back-end REST service

REST endpoint import hudson.extension; import io.jenkins.blueocean.rest.organizationroute; import io.jenkins.blueocean.rest.model.resource; import org.kohsuke.stapler.export.exported; import org.kohsuke.stapler.export.exportedbean; @Extension @ExportedBean public class Computers extends Resource implements OrganizationRoute {

REST endpoint @Override public String geturlname() { return "computers"; } @Override public Link getlink() { return getorganization().getlink().rel(geturlname()); }

REST endpoint @Exported(inline=true) public ComputerInfo[] getcomputers() throws Exception { // some code here }... @Exported public String getdisplayname() { return computer.getdisplayname(); }

Provide configuration to the BO UI import io.jenkins.blueocean.commons.pagestatepreloader; @Extension public class ExecutorinfoPreloader extends PageStatePreloader { static boolean showexecutorinfo = // get sys property public String getstatepropertypath() { return "executor"; } public String getstatejson() { return "{showinfo:" + showexecutorinfo + "}"; } }

Provide configuration to the BO UI // In JenkinsScript: import { blueocean } from '@jenkins-cd/blueocean-core-js/dist/js/scopes'; blueocean.executor.showinfo

Constructing the plugin Front-end extensions

Modern Javascript: Babel Add.babelrc { "presets": ["es2015", "stage-0", "react"], "plugins": [ "transform-decorators-legacy" ] }

Find Extension Points Well maintained extension list: git clone https://github.com/jenkinsci/blueocean-plugin cd blueocean-plugin grep -r "extensionpoint=" $(find. -maxdepth 2 -name src)

jenkins-js-extension.yaml # Extensions in this plugin extensions: - component: Routes extensionpoint: jenkins.main.routes - component: TopLink extensionpoint: jenkins.blueocean.top.links...

Routes.jsx import { Route } from 'react-router'; import { ExecutorInfoPage } from './ExecutorInfoPage'; export default ( <Route path="/organizations/:organization/executor-info" component={executorinfopage} /> );

TopLink.jsx import React from 'react'; // Need in all JSX files import { Link } from 'react-router'; // Links to a Route import { AppConfig } from '@jenkins-cd/blueocean-core-js'; export default () => <Link to={`/organizations/${appconfig.getorganizationname()}/executor-i nfo`} title="executor Information">Executors</Link>;

ExecutorInfoService.js import { observable, action } from 'mobx'; import { Fetch, UrlConfig, AppConfig, sseconnection } from '@jenkins-cd/blueocean-core-js'; export class ExecutorInfoService { @observable // makes this property managed by MobX computers; @action setcomputers(computers) { this.computers = computers;

ExecutorInfoService.js import { Fetch, UrlConfig, AppConfig, sseconnection } from '@jenkins-cd/blueocean-core-js'; constructor() { this.fetchexecutorinfo(); sseconnection.subscribe('pipeline', event => { switch (event.jenkins_event) { case 'pipeline_block_start': case 'pipeline_block_end': { this.fetchexecutorinfo(); }

ExecutorInfoService.js import { Fetch, UrlConfig, AppConfig, sseconnection } from '@jenkins-cd/blueocean-core-js'; fetchexecutorinfo() { Fetch.fetchJSON(`${UrlConfig.getRestBaseURL()}/organizations/${Ap pconfig.getorganizationname()}/computers/`).then(response => { this.setcomputers(response.computers); }); }

ExecutorInfoService.js // Export an instance to be shared so sseconnection.subscribe // not called multiple times export default new ExecutorInfoService();

ExecutorInfoPage.jsx import { observer } from 'mobx-react'; @observer // MobX magic automatically re-render for observable export class ExecutorInfoPage extends React.Component { render() { return ( <JTable columns={columns} classname="executor-info-table"> <TableHeaderRow />...

ExecutorInfoPage.jsx import executorinfoservice from './ExecutorInfoService';... render() {... {executorinfoservice.computers && // important pattern or errors executorinfoservice.computers.map(computer => [ <TableRow>...

Defining Extension Points

Defining Extension Points Extensions object from js-extensions Extensions.Renderer renders all React component extensions extensionpoint property optional filter attribute for various things like ordinals all other properties passed through to the extensions

Defining Extension Points import Extensions from '@jenkins-cd/js-extensions';... render() {... <Extensions.Renderer extensionpoint="jenkins.pipeline.run.list.display" filter={sortbyordinal} run={branch} // passed to the extensions

Demo

Future Improvements * In the pipeline * subject to change

Improvements Finding ExtensionPoints Allow developers to run in a developmentmode UI hints/info where UI extension points are Generate documentation from source

Improvements Defining Extensions Remove jenkins-js-extensions.yaml Provide decorators Allow more strongly typed extension points & inheritence Investigating providing TypeScript interface files

Improved Code Sharing Allow plugins to export arbitrary javascript objects Allow plugins to import from other plugins without npm

Questions?

Resources github.com/jenkinsci/blueocean-plugin github.com/kzantow/blueocean-executor-info-plugin