Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata

This functionality has been removed in Jenkins 2.0. While you can still bundle plugins, the pinned plugins functionality has been removed, resulting in plugins that cannot be updated by users, as they will be overwritten on next startup.

If you'd like to ship plugins pre-installed in jenkins.war, you can do so by placing your plugins inside jenkins.war as /WEB-INF/plugins/*.hpi.

These files will be extracted whenever Jenkins is started. This feature was added in 1.259.

There are several jars and plugins bundled in jenkins.war that way. The configuration usually goes to pom in war submodule of jenkins.

Sample

Here is a maven pom to build a Jenkins webapp bundled with your plugins:

	<repositories>
		<repository>
			<id>jenkins</id>
			<url>http://maven.jenkins-ci.org/content/repositories/releases/</url>
		</repository>
	</repositories>
	<dependencies>
		<dependency>
			<groupId>org.jenkins-ci.main</groupId>
			<artifactId>jenkins-war</artifactId>
			<version>[1.560,)</version>
			<type>war</type>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>copy</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<stripVersion>true</stripVersion>
					<artifactItems>
						<artifactItem>
							<groupId>${pom.groupId}</groupId>
							<artifactId>my_plugin1</artifactId>
							<version>${pom.version}</version>
							<type>hpi</type>
							<outputDirectory>${project.build.directory}/plugins</outputDirectory>
						</artifactItem>
						<artifactItem>
							<groupId>${pom.groupId}</groupId>
							<artifactId>my_plugin2</artifactId>
							<version>${pom.version}</version>
							<type>hpi</type>
							<outputDirectory>${project.build.directory}/plugins</outputDirectory>
						</artifactItem>
					</artifactItems>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<configuration>
					<archive>
						<manifest>
							<mainClass>Main</mainClass>
						</manifest>
						<manifestEntries>
							<Jenkins-Version>${project.version}</Jenkins-Version>
						</manifestEntries>
					</archive>
					<webResources>
						<resource>
							<directory>${project.build.directory}/plugins</directory>
							<targetPath>WEB-INF/plugins</targetPath>
						</resource>
					</webResources>
				</configuration>
			</plugin>


		</plugins>
	</build>

Here is an Ant target that bundles all the plugins in the ./plugins subdirectory into a new jenkins.war file.

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="Jenkins-Bundle">

    <property name="src.war" value="download/jenkins.war" />
    <property name="dist" value="dist" />
    <property name="plugins.dir" value="plugins" />

    <target name="bundle" description="Merge plugins in ./plugins into a custom jenkins.war">
        <mkdir dir="${dist}" />
        <zip destfile="${dist}/jenkins.war">
            <zipfileset src="${src.war}" />
            <zipfileset dir="${plugins.dir}" prefix="WEB-INF/plugins" />
        </zip>
    </target>

    <target name="distclean">
        <delete dir="${dist}" />
    </target>

</project>

  • No labels

1 Comment

  1. Unknown User (junk111970@gmail.com)

    This might also be due to my lack of understanding Maven, but how do you bundle jars with a plugin? For example, the Dimensions plugin requires 4 jars that also need to be in the classpath. These 4 jars are not included with the plugin because of licensing issues. I know where to include the .hpi.

    Thanks,
    Saad