What is the best way to download all the Jenkins plugins along with their dependencies?

7,206 views
Skip to first unread message

Hemant Gupta

unread,
Apr 1, 2016, 5:51:44 PM4/1/16
to Jenkins Users

I am thinking of writing a bash script(plugin.sh) that would download the plugins along with their dependencies.

I am also thinking of creating a text file(plugin.txt) where I would list the plugin and version that I need to download.

The bash script(plugin.sh) will take text file(plugin.txt) as an input and would download all the plugins along with their dependencies in the /var/lib/plugins


I am sure someone must have done this earlier. I will highly appreciate if you can provide a few references to it.

jieryn

unread,
Apr 1, 2016, 5:59:13 PM4/1/16
to Jenkins Users
The built plugin (.jpi / .hpi) already has its dependencies bundled
within it. Every plugin has a symlink to the latest version. This
seems like a pretty straightforward web crawler walk, downloading only
the /latest/ linkage from
http://updates.jenkins-ci.org/download/plugins/
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-use...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/4cc79c22-9c9c-4f11-91b2-f190c7d0f4e0%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Hemant Gupta

unread,
Apr 1, 2016, 6:28:04 PM4/1/16
to Jenkins Users
Thanks for response !!
I can write bash to download the plugin(.hpi) from the http://updates.jenkins-ci.org/download/plugins/ 

But, if I download a .hpi plugin file, it doesn't download the dependent .hpi files.
In other words, downloading a plugin doesn't download its dependencies.

Can you throw some light on writing the logic that would also download the dependencies?

jieryn

unread,
Apr 1, 2016, 6:50:14 PM4/1/16
to Jenkins Users

Ian Duffy

unread,
Apr 1, 2016, 7:06:13 PM4/1/16
to jenkins...@googlegroups.com
I build them all as RPMs and let yum resolve the dependencies.



Mark Waite

unread,
Apr 1, 2016, 8:17:36 PM4/1/16
to jenkins...@googlegroups.com
If the goal is to download and install the plugins and their dependencies, you could use the jenkins-cli.jar file and make command line calls to Jenkins itself.  I think it will then resolve the dependencies for you.

Mark Waite

Hemant Gupta

unread,
Apr 4, 2016, 5:44:21 PM4/4/16
to Jenkins Users
thanks for your responses.

How can i use jenkins-cli.jar file to modify the below curl command:
curl -o $PLUGIN_DIR/$name-$Version.hpi $JENKINS_PLUGINS_URL/$name/$latest_version/$name.hpi

Indra Gunawan (ingunawa)

unread,
Apr 4, 2016, 7:42:53 PM4/4/16
to jenkins...@googlegroups.com
Argument "SOURCE" is required
java -jar jenkins-cli.jar install-plugin SOURCE ... [-deploy] [-name VAL] [-restart] [--username VAL] [--password VAL] [--password-file VAL]
Installs a plugin either from a file, an URL, or from update center.
 SOURCE              : If this points to a local file, that file will be
                       installed. If this is an URL, Jenkins downloads the URL
                       and installs that as a plugin.Otherwise the name is
                       assumed to be the short name of the plugin in the
                       existing update center (like "findbugs"),and the plugin
                       will be installed from the update center
 -deploy             : Deploy plugins right away without postponing them until
                       the reboot.
 -name VAL           : If specified, the plugin will be installed as this short
                       name (whereas normally the name is inferred from the
                       source name automatically.)
 -restart            : Restart Jenkins upon successful installation
 --username VAL      : User name to authenticate yourself to Jenkins
 --password VAL      : Password for authentication. Note that passing a
                       password in arguments is insecure.
 --password-file VAL : File that contains the password


The URL you are downloading a particular plugin is the SOURCE

Mark Waite

unread,
Apr 4, 2016, 9:33:07 PM4/4/16
to jenkins...@googlegroups.com
My apologies.  I was wrong.  It appears that the Jenkins command line interface in the 1.642.4 version does not automatically resolve dependencies (or at least it did not work for me).  I think that was the key problem you were trying to solve, so the command line interface won't help.

$ java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin 

Sorry for directing towards something without testing it myself first!

Mark Waite

Stephen Connolly

unread,
Apr 5, 2016, 6:08:37 AM4/5/16
to jenkins...@googlegroups.com
A pom of <packaging>pom</packaging> where you list the required plugins as  <dependency> where the <type>hpi</type> is used can do the download for you. Here is a snippet showing what you need to do (this is also used in creating the Jenkins 1.x WAR files and if it isn't then it should have been

<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>metrics</artifactId>
<version>3.1.2.5</version>
<type>hpi</type>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>1.115</version>
<executions>
<execution>
<goals>
<goal>bundle-plugins</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${project.build.finalName}/plugins/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

Reply all
Reply to author
Forward
0 new messages