问题
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