SlideShare a Scribd company logo
Your own full blown
Gerrit plugin.
2014 Dariusz Łuksza
Dariusz Łuksza, CollabNet
dariusz@luksza.org
@dluksza
2014 Dariusz Łuksza
Preconditions
● Basic concept of Dependeny Injection (or have
open mind to grasp it during presentation)
● POSIX compatibe operating system (Linux or
Mac... or Windows with cygwin, sshd is
required)
● Being familiar with JavaScript
● Maven
2014 Dariusz Łuksza
How Gerrit and Jenkins Gerrit
Trigger plugin works?
Trigger buld
Push
Retrigger build
Post comments
Send email
developer
2014 Dariusz Łuksza
What we will build?1
2
3
Plus maven configuration to build and
deploy plugin in running Gerrit instance.
2014 Dariusz Łuksza
What it requires?
● REST endpoint – to schedule a build and
receive confirmation
● UI Action – part of Gerrit Web UI that will show
button on change screen and popups
● Capabilities – so that only members of given
groups can retrigger builds
● Two HTTP calls from Gerrit to CI server – this
is implementation detail, how we actually
retrigger build
Initialize project
2014 Dariusz Łuksza
2014 Dariusz Łuksza
Add archetype catalog
Window → Preferences → Maven → Archetypes
First of all you need to add remote archetype
catalog to Eclipse... don't know why
repo1.maven.org is not on the default list.
2014 Dariusz Łuksza
Create project from archetype
Ctrl + n → Maven → Maven Project → Next x2
Fill out those addional
archetype properties
2014 Dariusz Łuksza
Default project structure
You can also provide
documentation for plugin ;)
Automated plugin
deployment
2014 Dariusz Łuksza
2014 Dariusz Łuksza
How to intall plugin in gerrit?
● Copy jar file to $gerrit_home/plugins directory
– Works fine in local development environment but could
be not compatible with integration tests
or
● Use Gerrit ssh command to install it remotley
– Plugin jar file must be on server file system
– Use scp command to copy plugin jar file, then gerrit ssh
command to install it
– Requires additional setting in $gerrit_site/etc/gerrit.config:
[plugins]
allowRemoteAdmin = true
2014 Dariusz Łuksza
How to deploy plugin from
command line?
$ scp username@gerrit.host /path/to/plugin/file.jar /tmp/
$ ssh -p 4918 gerrit_username@gerrit.host gerrit plugin
install /tmp/jar.file
First operation require SSHD running on the server
and system account.
Second, require account in Gerrit (this is different
then one used in first step) and membership in Gerrit
Administrators group*.
* or Administrate Server capability
2014 Dariusz Łuksza
Deploy from Maven? Yes, we can!
Those lines goes on and on... On last
slide you will find link to repository
that contains this pom.xml file
2014 Dariusz Łuksza
And missing Maven profile setting
systemUser name is used
in scp command
deployUser should be
member of Gerrit
Administrators group*.
Plus have SSH public
key in Gerrit of local
system user.
* or have Administrate Server capability
2014 Dariusz Łuksza
And we are good to go!
Now you can simply type `mvn verify` to
deploy newest plugin version in running Gerrit
Our two commands
being executed
Configure your plugin
2014 Dariusz Łuksza
2014 Dariusz Łuksza
Configure plugin in gerrit.config
● Add:
[plugin "RetriggerMe"]
jenkinsUrl = http://localhost:9090/
selfName = localhost 8080
to $gerrit_site/etc/gerrit.config and restart Gerrit
● From now on, our plugin must be installed
under `RetriggerMe` name. Otherwise it will not
see this configuration.
2014 Dariusz Łuksza
Let's start from plugin configuration!
pluginName will contain name
under which our plugin was
installed in Gerrit, annotation
here is very important. That
value is dynamically bound in
plugin context during
installation process.
Extract `jenkinsUrl` and `selfName` from
$gerrit_site/etc/gerrit.config file
Don't forget about @Inject
Communicate with
outside world via REST
endpoints
2014 Dariusz Łuksza
2014 Dariusz Łuksza
Let's communicate with outside
world! - REST end points
Will be automatically
serialized to JSON
before sending to client.
Inject our configuration provider
Implement proper interface
2014 Dariusz Łuksza
Let's communicate with outside
world! - REST end points
Inform Gerrit that we want to have our REST
enpoint to be registered in `change` context,
with name `retrigger`. This is another part of
Gerrit's Guice magic ;)
2014 Dariusz Łuksza
Let's communicate with outside
world! - REST end points
Install our child Guice module in
main plugin module.
2014 Dariusz Łuksza
Let's communicate with outside
world! - REST end points
Let's test it:
$ mvn verify
$ curl -X POST –digest 
http://admin:tJESZhrTpZGm@localhost:8080/a/changes/2/RetriggerMe~retrigger
)]}'
{
"jenkins_url": "http://localhost:9090/"
}
Generated HTTP
password for admin user
Name under which
plugin was installed
REST endpoint name
Response
Context name
Response always starts with magic “)]}'” prefix. This is preventing
from JavaScript injection, this is a security feature of Gerrit.
Extend Web UI
2014 Dariusz Łuksza
2014 Dariusz Łuksza
Add button on Web UI
Add UiAction interface
2014 Dariusz Łuksza
Add button on Web UI
Handle button
`onclick` action
Gerrit's
JavaScript
magic ;)
Context
name
Our REST
endpoint
name
2014 Dariusz Łuksza
Communicate back to server
Callback function
Call associated
REST endpoint
Note object fields naming
convention (underscores)
2014 Dariusz Łuksza
Handle data from client and trigger
build
Input datastructure, remember
about name convention,
camelCase in Java,
underscores_in_java_script
Gerrit will automatically deserialize JSON to Java object
Extend Gerrit
permission system
2014 Dariusz Łuksza
2014 Dariusz Łuksza
Protect retrigger button with plugin
own capability
Extend
CapabilityDefinition
class
2014 Dariusz Łuksza
Protect retrigger button with plugin
own capability
Grant our plugin
capability to users group
Configuring capabilities requires changes in All-Projects access rights.
2014 Dariusz Łuksza
Protect retrigger button with plugin
own capability
Bind it in plugin
main module
2014 Dariusz Łuksza
Protect retrigger button with plugin
own capability
Anotate our UiAction with
@RequiresCapability
And that is it! Only members of groups with `retrigger` capability will
see `Retrigger Me!` button in Web UI.
Debugging?
2014 Dariusz Łuksza
2014 Dariusz Łuksza
How to debug?
● Modify $gerrit_site/etc/gerrit.config:
[container]
javaOptions = -Xdebug
-Xrunjdwp:transport=dt_socket,address=8998,server=y,suspend=n
● Use 'Remote debug' from Eclipse :)
2014 Dariusz Łuksza
Dariusz Łuksza, CollabNet
dariusz@luksza.org
@dluksza
Thank you!
Questions?
Links:
● Gerrit documentation:
https://gerrit-documentation.storage.googleapis.com/Documentation/2.9/index.html
Plugins development part:
https://gerrit-documentation.storage.googleapis.com/Documentation/2.9/dev-plugins.html
JavaScript API part:
https://gerrit-documentation.storage.googleapis.com/Documentation/2.9/js-api.html
● RetriggerMe source:
https://github.com/dluksza/gerrit-retriggerme
● Presentation:
http://www.slideshare.net/dluksza/gerrit-plugins
● Create Gerrit Web UI plugins using AngularJS:
https://github.com/dluksza/angular-gerrit

More Related Content

What's hot

Ingress overview
Ingress overviewIngress overview
Ingress overview
Harshal Shah
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version Control
Sourabh Sahu
 
GitOps - Operation By Pull Request
GitOps - Operation By Pull RequestGitOps - Operation By Pull Request
GitOps - Operation By Pull Request
Kasper Nissen
 
Introduction to Gitlab
Introduction to GitlabIntroduction to Gitlab
Introduction to GitlabJulien Pivotto
 
Gerrit Code Review: how to script a plugin with Scala and Groovy
Gerrit Code Review: how to script a plugin with Scala and GroovyGerrit Code Review: how to script a plugin with Scala and Groovy
Gerrit Code Review: how to script a plugin with Scala and Groovy
Luca Milanesio
 
Get started with gitops and flux
Get started with gitops and fluxGet started with gitops and flux
Get started with gitops and flux
LibbySchulze1
 
Best practices for implementing CI/CD on Salesforce
Best practices for implementing CI/CD on SalesforceBest practices for implementing CI/CD on Salesforce
Best practices for implementing CI/CD on Salesforce
AIMDek Technologies
 
Git 101
Git 101Git 101
Github
GithubGithub
Github
Nikhil Baby
 
Gitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeGitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTree
Teerapat Khunpech
 
Designing a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd productsDesigning a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd products
Julian Mazzitelli
 
Gerrit Code Review migrations step-by-step
Gerrit Code Review migrations step-by-stepGerrit Code Review migrations step-by-step
Gerrit Code Review migrations step-by-step
Luca Milanesio
 
Role Based Access Controls (RBAC) for SSH and Kubernetes Access with Teleport
Role Based Access Controls (RBAC) for SSH and Kubernetes Access with TeleportRole Based Access Controls (RBAC) for SSH and Kubernetes Access with Teleport
Role Based Access Controls (RBAC) for SSH and Kubernetes Access with Teleport
DevOps.com
 
Argocd up and running
Argocd up and runningArgocd up and running
Argocd up and running
Raphaël PINSON
 
Schedulers and Timers in Akka
Schedulers and Timers in AkkaSchedulers and Timers in Akka
Schedulers and Timers in Akka
Knoldus Inc.
 
Control Kubernetes Ingress and Egress Together with NGINX
Control Kubernetes Ingress and Egress Together with NGINXControl Kubernetes Ingress and Egress Together with NGINX
Control Kubernetes Ingress and Egress Together with NGINX
NGINX, Inc.
 
Meetup 23 - 03 - Application Delivery on K8S with GitOps
Meetup 23 - 03 - Application Delivery on K8S with GitOpsMeetup 23 - 03 - Application Delivery on K8S with GitOps
Meetup 23 - 03 - Application Delivery on K8S with GitOps
Vietnam Open Infrastructure User Group
 
Tracking Huge Files with Git LFS
Tracking Huge Files with Git LFSTracking Huge Files with Git LFS
Tracking Huge Files with Git LFS
Atlassian
 
Gitops: the kubernetes way
Gitops: the kubernetes wayGitops: the kubernetes way
Gitops: the kubernetes way
sparkfabrik
 
Overview of github
Overview of githubOverview of github
Overview of github
Sangeetha Subramani
 

What's hot (20)

Ingress overview
Ingress overviewIngress overview
Ingress overview
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version Control
 
GitOps - Operation By Pull Request
GitOps - Operation By Pull RequestGitOps - Operation By Pull Request
GitOps - Operation By Pull Request
 
Introduction to Gitlab
Introduction to GitlabIntroduction to Gitlab
Introduction to Gitlab
 
Gerrit Code Review: how to script a plugin with Scala and Groovy
Gerrit Code Review: how to script a plugin with Scala and GroovyGerrit Code Review: how to script a plugin with Scala and Groovy
Gerrit Code Review: how to script a plugin with Scala and Groovy
 
Get started with gitops and flux
Get started with gitops and fluxGet started with gitops and flux
Get started with gitops and flux
 
Best practices for implementing CI/CD on Salesforce
Best practices for implementing CI/CD on SalesforceBest practices for implementing CI/CD on Salesforce
Best practices for implementing CI/CD on Salesforce
 
Git 101
Git 101Git 101
Git 101
 
Github
GithubGithub
Github
 
Gitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeGitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTree
 
Designing a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd productsDesigning a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd products
 
Gerrit Code Review migrations step-by-step
Gerrit Code Review migrations step-by-stepGerrit Code Review migrations step-by-step
Gerrit Code Review migrations step-by-step
 
Role Based Access Controls (RBAC) for SSH and Kubernetes Access with Teleport
Role Based Access Controls (RBAC) for SSH and Kubernetes Access with TeleportRole Based Access Controls (RBAC) for SSH and Kubernetes Access with Teleport
Role Based Access Controls (RBAC) for SSH and Kubernetes Access with Teleport
 
Argocd up and running
Argocd up and runningArgocd up and running
Argocd up and running
 
Schedulers and Timers in Akka
Schedulers and Timers in AkkaSchedulers and Timers in Akka
Schedulers and Timers in Akka
 
Control Kubernetes Ingress and Egress Together with NGINX
Control Kubernetes Ingress and Egress Together with NGINXControl Kubernetes Ingress and Egress Together with NGINX
Control Kubernetes Ingress and Egress Together with NGINX
 
Meetup 23 - 03 - Application Delivery on K8S with GitOps
Meetup 23 - 03 - Application Delivery on K8S with GitOpsMeetup 23 - 03 - Application Delivery on K8S with GitOps
Meetup 23 - 03 - Application Delivery on K8S with GitOps
 
Tracking Huge Files with Git LFS
Tracking Huge Files with Git LFSTracking Huge Files with Git LFS
Tracking Huge Files with Git LFS
 
Gitops: the kubernetes way
Gitops: the kubernetes wayGitops: the kubernetes way
Gitops: the kubernetes way
 
Overview of github
Overview of githubOverview of github
Overview of github
 

Similar to Your own full blown Gerrit plugin

Build Your Own HiveMQ Extension
Build Your Own HiveMQ ExtensionBuild Your Own HiveMQ Extension
Build Your Own HiveMQ Extension
HiveMQ
 
Tame Your Build And Deployment Process With Hudson, PHPUnit, and SSH
Tame Your Build And Deployment Process With Hudson, PHPUnit, and SSHTame Your Build And Deployment Process With Hudson, PHPUnit, and SSH
Tame Your Build And Deployment Process With Hudson, PHPUnit, and SSH
David Stockton
 
Docker
DockerDocker
Null bhopal Sep 2016: What it Takes to Secure a Web Application
Null bhopal Sep 2016: What it Takes to Secure a Web ApplicationNull bhopal Sep 2016: What it Takes to Secure a Web Application
Null bhopal Sep 2016: What it Takes to Secure a Web Application
Anant Shrivastava
 
DevOps: Cooking Drupal Deployment
DevOps: Cooking Drupal DeploymentDevOps: Cooking Drupal Deployment
DevOps: Cooking Drupal Deployment
Gerald Villorente
 
Secure real-time collaboration with SecurePass and Etherpad
Secure real-time collaboration with SecurePass and EtherpadSecure real-time collaboration with SecurePass and Etherpad
Secure real-time collaboration with SecurePass and EtherpadGiuseppe Paterno'
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
Duke Dao
 
Drupal Continuous Integration with Jenkins - Deploy
Drupal Continuous Integration with Jenkins - DeployDrupal Continuous Integration with Jenkins - Deploy
Drupal Continuous Integration with Jenkins - Deploy
John Smith
 
Zend Framework Foundations
Zend Framework FoundationsZend Framework Foundations
Zend Framework Foundations
Chuck Reeves
 
How to manage Azure with open source
How to manage Azure with open sourceHow to manage Azure with open source
How to manage Azure with open source
Ubuntu Korea Community
 
How to manage Microsoft Azure with open source
How to manage Microsoft Azure with open sourceHow to manage Microsoft Azure with open source
How to manage Microsoft Azure with open source
Taehee Jang
 
Pyramid Deployment and Maintenance
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and Maintenance
Jazkarta, Inc.
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with Capistrano
Ramazan K
 
Hadoop Security Preview
Hadoop Security PreviewHadoop Security Preview
Hadoop Security Preview
Hadoop User Group
 
Hadoop Security Preview
Hadoop Security PreviewHadoop Security Preview
Hadoop Security Preview
Hadoop User Group
 
Hadoop Security Preview
Hadoop Security PreviewHadoop Security Preview
Hadoop Security Preview
Hadoop User Group
 
Development Setup of B-Translator
Development Setup of B-TranslatorDevelopment Setup of B-Translator
Development Setup of B-Translator
Dashamir Hoxha
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Dana Luther
 
2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle
2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle
2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle
garrett honeycutt
 
Setting Up a Cloud Server - Part 1 - Transcript.pdf
Setting Up a Cloud Server - Part 1 - Transcript.pdfSetting Up a Cloud Server - Part 1 - Transcript.pdf
Setting Up a Cloud Server - Part 1 - Transcript.pdf
ShaiAlmog1
 

Similar to Your own full blown Gerrit plugin (20)

Build Your Own HiveMQ Extension
Build Your Own HiveMQ ExtensionBuild Your Own HiveMQ Extension
Build Your Own HiveMQ Extension
 
Tame Your Build And Deployment Process With Hudson, PHPUnit, and SSH
Tame Your Build And Deployment Process With Hudson, PHPUnit, and SSHTame Your Build And Deployment Process With Hudson, PHPUnit, and SSH
Tame Your Build And Deployment Process With Hudson, PHPUnit, and SSH
 
Docker
DockerDocker
Docker
 
Null bhopal Sep 2016: What it Takes to Secure a Web Application
Null bhopal Sep 2016: What it Takes to Secure a Web ApplicationNull bhopal Sep 2016: What it Takes to Secure a Web Application
Null bhopal Sep 2016: What it Takes to Secure a Web Application
 
DevOps: Cooking Drupal Deployment
DevOps: Cooking Drupal DeploymentDevOps: Cooking Drupal Deployment
DevOps: Cooking Drupal Deployment
 
Secure real-time collaboration with SecurePass and Etherpad
Secure real-time collaboration with SecurePass and EtherpadSecure real-time collaboration with SecurePass and Etherpad
Secure real-time collaboration with SecurePass and Etherpad
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
 
Drupal Continuous Integration with Jenkins - Deploy
Drupal Continuous Integration with Jenkins - DeployDrupal Continuous Integration with Jenkins - Deploy
Drupal Continuous Integration with Jenkins - Deploy
 
Zend Framework Foundations
Zend Framework FoundationsZend Framework Foundations
Zend Framework Foundations
 
How to manage Azure with open source
How to manage Azure with open sourceHow to manage Azure with open source
How to manage Azure with open source
 
How to manage Microsoft Azure with open source
How to manage Microsoft Azure with open sourceHow to manage Microsoft Azure with open source
How to manage Microsoft Azure with open source
 
Pyramid Deployment and Maintenance
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and Maintenance
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with Capistrano
 
Hadoop Security Preview
Hadoop Security PreviewHadoop Security Preview
Hadoop Security Preview
 
Hadoop Security Preview
Hadoop Security PreviewHadoop Security Preview
Hadoop Security Preview
 
Hadoop Security Preview
Hadoop Security PreviewHadoop Security Preview
Hadoop Security Preview
 
Development Setup of B-Translator
Development Setup of B-TranslatorDevelopment Setup of B-Translator
Development Setup of B-Translator
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
 
2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle
2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle
2014-11-11 Multiple Approaches to Managing Puppet Modules @ Puppet Camp Seattle
 
Setting Up a Cloud Server - Part 1 - Transcript.pdf
Setting Up a Cloud Server - Part 1 - Transcript.pdfSetting Up a Cloud Server - Part 1 - Transcript.pdf
Setting Up a Cloud Server - Part 1 - Transcript.pdf
 

More from Dariusz Łuksza

A story of 715 commits… in ~15 minutes

A story of 715 commits… in ~15 minutes
A story of 715 commits… in ~15 minutes

A story of 715 commits… in ~15 minutes

Dariusz Łuksza
 
One Man App
One Man AppOne Man App
One Man App
Dariusz Łuksza
 
Guiding Diffy to the Enterprise land
Guiding Diffy to the Enterprise landGuiding Diffy to the Enterprise land
Guiding Diffy to the Enterprise landDariusz Łuksza
 
Review your code like a Googler
Review your code like a GooglerReview your code like a Googler
Review your code like a Googler
Dariusz Łuksza
 
Gerrit Code Review - The Introduction
Gerrit Code Review - The IntroductionGerrit Code Review - The Introduction
Gerrit Code Review - The Introduction
Dariusz Łuksza
 
Gerrit JavaScript Plugins
Gerrit JavaScript PluginsGerrit JavaScript Plugins
Gerrit JavaScript Plugins
Dariusz Łuksza
 
Eclipse of idleness and focus on current task (rev. 2)
Eclipse of idleness and focus on current task (rev. 2)Eclipse of idleness and focus on current task (rev. 2)
Eclipse of idleness and focus on current task (rev. 2)
Dariusz Łuksza
 

More from Dariusz Łuksza (9)

A story of 715 commits… in ~15 minutes

A story of 715 commits… in ~15 minutes
A story of 715 commits… in ~15 minutes

A story of 715 commits… in ~15 minutes

 
One Man App
One Man AppOne Man App
One Man App
 
Guiding Diffy to the Enterprise land
Guiding Diffy to the Enterprise landGuiding Diffy to the Enterprise land
Guiding Diffy to the Enterprise land
 
Review your code like a Googler
Review your code like a GooglerReview your code like a Googler
Review your code like a Googler
 
Git in Eclipse
Git in EclipseGit in Eclipse
Git in Eclipse
 
Put more eyes on code
Put more eyes on codePut more eyes on code
Put more eyes on code
 
Gerrit Code Review - The Introduction
Gerrit Code Review - The IntroductionGerrit Code Review - The Introduction
Gerrit Code Review - The Introduction
 
Gerrit JavaScript Plugins
Gerrit JavaScript PluginsGerrit JavaScript Plugins
Gerrit JavaScript Plugins
 
Eclipse of idleness and focus on current task (rev. 2)
Eclipse of idleness and focus on current task (rev. 2)Eclipse of idleness and focus on current task (rev. 2)
Eclipse of idleness and focus on current task (rev. 2)
 

Recently uploaded

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 

Recently uploaded (20)

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 

Your own full blown Gerrit plugin

  • 1. Your own full blown Gerrit plugin. 2014 Dariusz Łuksza Dariusz Łuksza, CollabNet dariusz@luksza.org @dluksza
  • 2. 2014 Dariusz Łuksza Preconditions ● Basic concept of Dependeny Injection (or have open mind to grasp it during presentation) ● POSIX compatibe operating system (Linux or Mac... or Windows with cygwin, sshd is required) ● Being familiar with JavaScript ● Maven
  • 3. 2014 Dariusz Łuksza How Gerrit and Jenkins Gerrit Trigger plugin works? Trigger buld Push Retrigger build Post comments Send email developer
  • 4. 2014 Dariusz Łuksza What we will build?1 2 3 Plus maven configuration to build and deploy plugin in running Gerrit instance.
  • 5. 2014 Dariusz Łuksza What it requires? ● REST endpoint – to schedule a build and receive confirmation ● UI Action – part of Gerrit Web UI that will show button on change screen and popups ● Capabilities – so that only members of given groups can retrigger builds ● Two HTTP calls from Gerrit to CI server – this is implementation detail, how we actually retrigger build
  • 7. 2014 Dariusz Łuksza Add archetype catalog Window → Preferences → Maven → Archetypes First of all you need to add remote archetype catalog to Eclipse... don't know why repo1.maven.org is not on the default list.
  • 8. 2014 Dariusz Łuksza Create project from archetype Ctrl + n → Maven → Maven Project → Next x2 Fill out those addional archetype properties
  • 9. 2014 Dariusz Łuksza Default project structure You can also provide documentation for plugin ;)
  • 11. 2014 Dariusz Łuksza How to intall plugin in gerrit? ● Copy jar file to $gerrit_home/plugins directory – Works fine in local development environment but could be not compatible with integration tests or ● Use Gerrit ssh command to install it remotley – Plugin jar file must be on server file system – Use scp command to copy plugin jar file, then gerrit ssh command to install it – Requires additional setting in $gerrit_site/etc/gerrit.config: [plugins] allowRemoteAdmin = true
  • 12. 2014 Dariusz Łuksza How to deploy plugin from command line? $ scp username@gerrit.host /path/to/plugin/file.jar /tmp/ $ ssh -p 4918 gerrit_username@gerrit.host gerrit plugin install /tmp/jar.file First operation require SSHD running on the server and system account. Second, require account in Gerrit (this is different then one used in first step) and membership in Gerrit Administrators group*. * or Administrate Server capability
  • 13. 2014 Dariusz Łuksza Deploy from Maven? Yes, we can! Those lines goes on and on... On last slide you will find link to repository that contains this pom.xml file
  • 14. 2014 Dariusz Łuksza And missing Maven profile setting systemUser name is used in scp command deployUser should be member of Gerrit Administrators group*. Plus have SSH public key in Gerrit of local system user. * or have Administrate Server capability
  • 15. 2014 Dariusz Łuksza And we are good to go! Now you can simply type `mvn verify` to deploy newest plugin version in running Gerrit Our two commands being executed
  • 16. Configure your plugin 2014 Dariusz Łuksza
  • 17. 2014 Dariusz Łuksza Configure plugin in gerrit.config ● Add: [plugin "RetriggerMe"] jenkinsUrl = http://localhost:9090/ selfName = localhost 8080 to $gerrit_site/etc/gerrit.config and restart Gerrit ● From now on, our plugin must be installed under `RetriggerMe` name. Otherwise it will not see this configuration.
  • 18. 2014 Dariusz Łuksza Let's start from plugin configuration! pluginName will contain name under which our plugin was installed in Gerrit, annotation here is very important. That value is dynamically bound in plugin context during installation process. Extract `jenkinsUrl` and `selfName` from $gerrit_site/etc/gerrit.config file Don't forget about @Inject
  • 19. Communicate with outside world via REST endpoints 2014 Dariusz Łuksza
  • 20. 2014 Dariusz Łuksza Let's communicate with outside world! - REST end points Will be automatically serialized to JSON before sending to client. Inject our configuration provider Implement proper interface
  • 21. 2014 Dariusz Łuksza Let's communicate with outside world! - REST end points Inform Gerrit that we want to have our REST enpoint to be registered in `change` context, with name `retrigger`. This is another part of Gerrit's Guice magic ;)
  • 22. 2014 Dariusz Łuksza Let's communicate with outside world! - REST end points Install our child Guice module in main plugin module.
  • 23. 2014 Dariusz Łuksza Let's communicate with outside world! - REST end points Let's test it: $ mvn verify $ curl -X POST –digest http://admin:tJESZhrTpZGm@localhost:8080/a/changes/2/RetriggerMe~retrigger )]}' { "jenkins_url": "http://localhost:9090/" } Generated HTTP password for admin user Name under which plugin was installed REST endpoint name Response Context name Response always starts with magic “)]}'” prefix. This is preventing from JavaScript injection, this is a security feature of Gerrit.
  • 24. Extend Web UI 2014 Dariusz Łuksza
  • 25. 2014 Dariusz Łuksza Add button on Web UI Add UiAction interface
  • 26. 2014 Dariusz Łuksza Add button on Web UI Handle button `onclick` action Gerrit's JavaScript magic ;) Context name Our REST endpoint name
  • 27. 2014 Dariusz Łuksza Communicate back to server Callback function Call associated REST endpoint Note object fields naming convention (underscores)
  • 28. 2014 Dariusz Łuksza Handle data from client and trigger build Input datastructure, remember about name convention, camelCase in Java, underscores_in_java_script Gerrit will automatically deserialize JSON to Java object
  • 30. 2014 Dariusz Łuksza Protect retrigger button with plugin own capability Extend CapabilityDefinition class
  • 31. 2014 Dariusz Łuksza Protect retrigger button with plugin own capability Grant our plugin capability to users group Configuring capabilities requires changes in All-Projects access rights.
  • 32. 2014 Dariusz Łuksza Protect retrigger button with plugin own capability Bind it in plugin main module
  • 33. 2014 Dariusz Łuksza Protect retrigger button with plugin own capability Anotate our UiAction with @RequiresCapability And that is it! Only members of groups with `retrigger` capability will see `Retrigger Me!` button in Web UI.
  • 35. 2014 Dariusz Łuksza How to debug? ● Modify $gerrit_site/etc/gerrit.config: [container] javaOptions = -Xdebug -Xrunjdwp:transport=dt_socket,address=8998,server=y,suspend=n ● Use 'Remote debug' from Eclipse :)
  • 36. 2014 Dariusz Łuksza Dariusz Łuksza, CollabNet dariusz@luksza.org @dluksza Thank you! Questions? Links: ● Gerrit documentation: https://gerrit-documentation.storage.googleapis.com/Documentation/2.9/index.html Plugins development part: https://gerrit-documentation.storage.googleapis.com/Documentation/2.9/dev-plugins.html JavaScript API part: https://gerrit-documentation.storage.googleapis.com/Documentation/2.9/js-api.html ● RetriggerMe source: https://github.com/dluksza/gerrit-retriggerme ● Presentation: http://www.slideshare.net/dluksza/gerrit-plugins ● Create Gerrit Web UI plugins using AngularJS: https://github.com/dluksza/angular-gerrit