Jenkins REST Plugin

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

NOTE: This idea is published as a draft under active discussion, but it is confirmed in principle. It is FINE to apply to it. The scope and the suggested implementation may change significantly before the final version is published. Sections like quickstart guide and newbie-friendly issues may be also missing. As a contributor, you are welcome to request additional information and to join the discussions using channels linked on this page.

Details

Project Idea

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.

Quick start

There are many technologies to use together to form this plugin. The student who wishes to get started will need to:

Skills to study/improve

  • Java

  • REST API

  • Jenkins Pipeline

Potential Mentors

Project Links

Organization Links

> Go back to other GSoC 2020 project ideas