UdhanIsuranga
UdhanIsuranga

Reputation: 151

How to add plugins to jenkins programmatically

I was trying to find a method to add plugins to Jenkins programmatically and found this answer useful. It shows a method using the following curl command and restarting Jenkins after that.

curl -X POST -d '<jenkins><install plugin="plugin-name@version" /></jenkins>' --header 'Content-Type: text/xml' http://localhost:8080/pluginManager/installNecessaryPlugins

It worked successfully for many plugins, but it failed for some plugins like Pipeline and Amazon EC2. Below is the command I used to install Pipeline plugin.

curl -X POST -d '<jenkins><install plugin="[email protected]" /></jenkins>' --header 'Content-Type: text/xml' http://localhost:8080/pluginManager/installNecessaryPlugins

How can I fix this?

Upvotes: 0

Views: 654

Answers (1)

Tirex
Tirex

Reputation: 494

You need to specify plugin-id in request.

You can find your plugin on https://plugins.jenkins.io and get plugin-id from description.

For example Declarative pipeline plugin (https://plugins.jenkins.io/pipeline-model-definition) has id pipeline-model-definition

Pipeline: Declarative1.3.9
Minimum Jenkins requirement: 2.150.1
ID: pipeline-model-definition

Upvotes: 1

Related Questions