Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a REST API for Jenkins plugins?

I'm trying to write a script that quickly checks if our Jenkins plugins are up to date. I know that this is a built in feature in Jenkins, but for security reasons, our Jenkins instance doesn't have internet access.

I know that I can get a lot of information about a plugin, including version, from:

https://plugins.jenkins.io/<name-of-plugin>

However, I can't get it to return anything other than HTML. I could scrape the HTML for the version number, but if there is a stable API that returns JSON or similar, that would be preferred. I'm pretty sure Jenkins isn't scraping HTML to check for updates, so the API must exist. Does anyone know where it is?

like image 551
Erik B Avatar asked Sep 18 '25 13:09

Erik B


1 Answers

There seem to be two solutions available. I ended up scraping:

https://updates.jenkins.io/download/plugins/<name-of-plugin>

The latest version is always in the second column of the second row, so scraping is trivial. It works well most of the time, but sometimes the connection is refused, which I assume might be due to of the volume of requests sent by the script.

Another option that I found is to download the following JSON file:

https://updates.jenkins.io/current/update-center.actual.json

It is currently 1.7MB and contains information about the latest version of all Jenkins plugins. It also contains meta data like dependencies, which allows your script to validate that all dependencies are satisfied.

Unfortunately I haven't found a way to download JSON for individual plugins, so you either have to scrape HTML for individual plugins or download a massive JSON for all plugins.

Update: I found the API:

https://plugins.jenkins.io/api/plugin/<name-of-plugin>

And I also found the source code and the documentation:

https://github.com/jenkins-infra/plugin-site-api

like image 77
Erik B Avatar answered Sep 21 '25 08:09

Erik B