Project goal: Create a new plugin to give Jenkins users the ability to make calls to other Jenkins instances via their REST API
Skills to study/improve: Java, REST API, Jenkins Pipeline
A Jenkins plugin to wrap the https://github.com/cdancy/jenkins-rest library, allowing Pipeline scripts to interact easily with other (or the self) Jenkins instances via the Jenkins REST API, and eliminating the need to parse responses, making pipeline scripts more concise.
Note: there are other java libraries for the Jenkins REST. The author of this proposal was only familiar with the aforementioned library. There is another library called the java client api, hosted in jenkins, which could also be used. The student is expected to compare these libraries and make a recommendation prior to starting the work.
This proposal is not about filling gaps in the Jenkins DSL.
From the Jenkins Pipeline DSL, we can call the http request plugin to talk to other services. But this plugin does not “understand” the responses, it simply returns the header and the body of the response to the user. It is up to the user to parse the JSON and extract the relevant pieces.
Interestingly, Jenkins itself has a REST API, so a Pipeline DSL could use the http request plugin to talk to the master Jenkins instance from an agent. But the user still to parse the response.
An object oriented approach, leveraging an existing library that parses the responses into objects would be easier for the user.
As explained in the mailing list, it is essential for build steps to return only simple data types, like string, integers, lists of simple data types, maps of simple data types. Steps cannot return methods, nor objects with behaviors. Also, using the GlobalVariable is not recommended, however it might be inevitable. The student is expected to study the use of GlobalVariable in plugins that use it and ask for guidance on the Pipeline Authoring SIG gitter chat on this matter. The student should study the docker pipeline plugin source code and the pipeline loader plugin to understand.
In the following, we show how the finished plugin would look like from the user point of view in a Jenkins Pipeline DSL program. This is not a specification, it is only an example. The student is expected to study the the jenkins-rest library, the Jenkins Plugin tutorials and the Scripted Pipeline syntax, and propose a proper Jenkins Pipeline DSL syntax for this project.
There are many technologies to use together to form this plugin. The student who wishes to get started will need to:
Try out Jenkins REST APIs
Try writing a small client using one of REST API Client libraries
study plugin tutorials on how to write a Pipeline Step plugin
create a basic custom pipeline compatible plugin and load it in Jenkins (see the plugin tutorials)
The two java rest api libraries:
Mailing list discussion: https://groups.google.com/forum/#!topic/jenkinsci-dev/x-EbjnWcFqs
Discussion on REST: https://groups.google.com/forum/#!topic/jenkinsci-dev/mYeM5qA6tGM