构建一个创建SimpleBuildStep
的Jenkins插件。
适用于maven hpi:run
,但我需要将其切换为gradle
我的问题是,当我运行gradle server
时,我可以看到我的自定义插件已安装,但它不在构建步骤中。
我认为这是我的版本,我改了好几次。我想知道我的配置是否错误。
我有一个显示的work
目录,我的插件显示在work/plugins/
中,其中包含.hpi
和.hpl
文件,但它仍然无法正常工作。它只适用于maven,当我做一个jenkins的docker实例(总是在jenkins版本2)时它也没有显示
我仍然认为这是我的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'
}
编辑:让它工作。我现在可以在我的实例中使用我的插件。
变更:
检查hpl
文件并阅读后。我意识到我的Jenkins插件甚至没有注册我的课程。我意识到因为我的build.gradle
位于根项目的一个文件夹中。显然我把build.gradle
移到了根目录中。
从那里我注意到它实际构建了这些类。仍然无法让我的插件实际显示为构建步骤,即使它出现在已安装(相同的旧问题)下。我从另一个插件中取了另一个build.gradle
并编辑供我自己使用。它有效,但我不明白为什么。
*我还必须添加一个缺少的依赖项,现在它实际上正在构建我的项目。
新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'
}
我怀疑它出于某种原因实际上与新的buildscripts
块有关
答案 0 :(得分:2)
您可能需要将小组设置为
group = 'org.jenkins-ci.plugins'
您可以删除
apply plugin 'java'
因为这是在内部完成的(我认为)
我不确定你是否需要包含ui-samples-plugin,但如果你这样做,则需要像
一样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'
}
(未测试的)
尝试使用wiki page获取更多信息