Calling internal methods of Jenkins plugin (thinBackup)

谁说我不能喝 提交于 2020-06-16 05:57:11

问题


I need to call internal functions of some Jenkins plugins that do not seem to be exposed via Jenkins CLI or remote api. For example, one of them is thinBackup and I'd like to call restore method avialable at https://github.com/jenkinsci/thin-backup-plugin/blob/master/src/main/java/org/jvnet/hudson/plugins/thinbackup/restore/HudsonRestore.java .

Is this possible using Java or Groovy (or any other method really, the simpler, the better)?


回答1:


You can set up dependencies between plugins as described here

Which for maven is by adding this to the pom.xml

<dependencies>
  <dependency>
    <groupId>org.jvnet.hudson.plugins</groupId>
    <artifactId>javanet-uploader</artifactId>
    <version>1.5</version>
  </dependency>
...
</dependencies>

Alternatively if you are using the gradle-jpi-plugin you add this to the build.gradle

dependencies {
    optionalJenkinsPlugins([group: 'org.jvnet.hudson.plugins', name: 'chucknorris', version: '0.5', ext: 'jar'])
    testCompile 'org.spockframework:spock-core:0.6-groovy-1.8'
    jenkinsTest 'org.jenkins-ci.plugins:ant:1.1@jar',
                'org.jenkins-ci.plugins:javadoc:1.0@jar'
}

This one here adds an optional dependency to chucknorris

The important thing to remember is that you can only call public methods whichever way you go



来源:https://stackoverflow.com/questions/25289797/calling-internal-methods-of-jenkins-plugin-thinbackup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!