Reputation: 2943
Building a Jenkins Plugin that creates a SimpleBuildStep
.
It works with maven hpi:run
but I need to switch it to gradle
My problem is that when I run gradle server
I can see my custom plugin is installed but it is not in the build step.
I thought it was my versioning and I changed it several times. I'm wondering if my configuration is wrong.
I have a work
directory that shows up and my plugin is shown in work/plugins/
with a .hpi
and a .hpl
file but it still doesn't work. It only works in maven it also doesn't show when I do a docker instance of jenkins (which is always at jenkins version 2)
I'm still assuming it is my build.gradle
plugins {
id "org.jenkins-ci.jpi" version "0.16.0"
}
jenkinsPlugin {
coreVersion = "2.0" // Version of Jenkins core this plugin depends on.
displayName = "Test Jenkins Plugin" // Human-readable name of plugin.
url = "http://wiki.jenkins-ci.org/display/JENKINS/SomePluginPage" // URL for plugin on Jenkins wiki or elsewhere.
shortName = "jetson" // Plugin ID, defaults to the project name without trailing '-plugin'
}
group 'test'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.5
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.jenkins-ci.main', name: 'ui-samples-plugin', version: '1.424.2'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
EDIT: Have it working. I can actually use my plugin in my instance now.
Changes:
After examining the hpl
file and reading it. I realized that my Jenkins plugin wasn't even registering my classes. I realized cause my build.gradle
was in a folder in the root project. So obviously I moved build.gradle
into the root.
From there I noticed it actually built those classes. Still couldn't get my plugin to actually show up as a build step even though it showed up under installed (same old problem). I took another build.gradle
from a different plugin and edited for my own use. It works, however I have no idea why.
*I also had to add a missing dependency I was having, now that it was actually building my project.
new build.gradle
:
buildscript {
repositories {
// The plugin is currently only available via the Jenkins
// Maven repository, but has dependencies in Maven Central.
mavenCentral()
maven {
url 'http://repo.jenkins-ci.org/releases/'
}
}
dependencies {
classpath 'org.jenkins-ci.tools:gradle-jpi-plugin:0.14.1'
}
}
apply plugin: 'java'
apply plugin: 'org.jenkins-ci.jpi'
repositories {
mavenCentral()
maven {
url "http://repo.jenkins-ci.org/releases/"
}
}
group = 'workday'
version = '0.1.0-SNAPSHOT'
description = 'Test AS A Service Plugin'
jenkinsPlugin {
// version of Jenkins core this plugin depends on, must be 1.420 or later
coreVersion = '1.654'
// ID of the plugin, defaults to the project name without trailing '-plugin'
shortName = 'jetson'
// human-readable name of plugin
displayName = 'Jetson Test Plugin'
// use the plugin class loader before the core class loader, defaults to false
pluginFirstClassLoader = true
// optional list of package prefixes that your plugin doesn't want to see from core
maskClasses = 'groovy.grape org.apache.commons.codec'
// optional version number from which this plugin release is configuration-compatible
compatibleSinceVersion = '1.1.0'
// enable injection of additional tests for checking the syntax of Jelly and other things
disabledTestInjection = false
// the output directory for the localizer task relative to the project root, defaults to the value shown
localizerOutputDir = "${project.buildDir}/generated-src/localizer"
// plugin file extension, either 'jpi' or 'hpi', defaults to 'hpi'
fileExtension = 'hpi'
}
dependencies {
compile group: 'org.jenkins-ci.main', name: 'ui-samples-plugin', version: '1.424.2'
compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.14'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
I suspect it actually has to do with the new buildscripts
blocks for some reason
Upvotes: 1
Views: 2022
Reputation: 9075
You probably need to set your group to
group = 'org.jenkins-ci.plugins'
and you can delete the
apply plugin 'java'
as this is done internally (I think)
I'm not sure you need to include the ui-samples-plugin either but if you do it needs to be something like
dependencies {
jenkinsPlugins( group: 'org.jenkins-ci.main',
name: 'ui-samples-plugin',
version: '1.424.2',
ext: 'jar')
testCompile group: 'junit', name: 'junit', version: '4.11'
}
(untested)
Try its wiki page for more info
Upvotes: 2