2016-12-21 95 views
1

构建一个Jenkins插件,创建一个SimpleBuildStepJenkins Plugin Development Gradle Build

它与maven hpi:run但我需要切换到gradle

我的问题是,当我运行gradle server我可以看到安装我的自定义插件,但它是不是在构建步骤。

我认为这是我的版本,我改变了几次。我想知道我的配置是否错误。

我有一个work目录,显示了和我的插件显示在work/plugins/.hpi.hpl文件,但它仍然无法正常工作。它只能在行家还当我做詹金斯的泊坞窗实例(总是在詹金斯第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块做某种原因

回答

2

你可能需要您的组设置为

group = 'org.jenkins-ci.plugins' 

和你可删除

apply plugin 'java' 

,因为这是内部完成的(我认为)

我不知道你需要包括UI样本 - 插件使用,但如果你做它需要像

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' 
} 

(未经测试)

尝试它的更多信息

+0

等待组wiki page在我的'jenkinsPlugin'块?我认为这个块是为了我自己关于像我的团体等插件的信息? –

+0

也在您发给我的wiki页面中,它甚至会像我一样说完成我所有的插件依赖项。你从哪里获得了添加插件的惯例? –

+1

我更新了我的答案。依赖关系在这里讨论https://docs.gradle.org/current/userguide/artifact_dependencies_tutorial.html如果你不打算发布插件 – KeepCalmAndCarryOn

相关问题